Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default frictionless CLI command #1095

Closed
roll opened this issue May 24, 2022 · 6 comments · Fixed by #1127
Closed

Add default frictionless CLI command #1095

roll opened this issue May 24, 2022 · 6 comments · Fixed by #1127
Assignees
Labels
feature New functionality

Comments

@roll
Copy link
Member

roll commented May 24, 2022

Overview

Currently, we have these commands:

  • frictionless describe
  • frictionless extract
  • frictionless validate
  • [coming] frictionless analyze
  • etc

We'd like to have (note there is no action):

$ frictionless table.csv

# Describe

[resource/schema as a table]

# Extract

[first X lines of the data as a table]

# Validate

## Summary

[validation summary table]

## Errors 

[validation errors table]
@roll roll added the feature New functionality label May 24, 2022
@shashigharti
Copy link
Contributor

@roll if user doesn't mention the action, it will run all three possible actions and show the results?

@roll
Copy link
Member Author

roll commented May 31, 2022

@shashigharti
It needs to be a new CLI command e.g. program.default:

resource = Resource('tabe.csv')
resource.infer()

# show schema as a table using resource.schema (let's prototype and discuss)

# show first X rows as a table using resource.extract

# show validation report using resource.validate

We don't need a new frictionless.actions for it -- just a new module in program

@shashigharti
Copy link
Contributor

@roll resource.schema.fields will not be nested in this usecase?

And to flatten json object what do you think of this library https://pypi.org/project/flatten-json/?

@roll
Copy link
Member Author

roll commented Jun 2, 2022

@shashigharti
Our goal is provide the most vital information regarding the schema, for example:

# Describe

field type required
-------------------
name1 string 
name2 number true
...

@roll
Copy link
Member Author

roll commented Jun 6, 2022

Currently, it doesn't seem to be possible to provide a default command the way we want with Typer - fastapi/typer#18

We will implement a normal command "summary" - frictionless summary table.csv - and then @roll will think how we can call it also as the default

@roll
Copy link
Member Author

roll commented Jun 6, 2022

@shashigharti
As a current quick-fix:

you can use this in `program.main' for program creation

# Program


# TODO: remove this hack when Typer supports not-found commands catching
# <link to the typer issue>
class Program(typer.Typer):
    def __call__(self, *args, **kwargs):
        if sys.argv[1].count("."):
            sys.argv = [sys.argv[0], "summary", sys.argv[1]]
        return super().__call__(*args, **kwargs)


program = Program()

Can you please also create a feature request for Typer? I would say that we'd like to have an ability to catch not found commands or something like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants