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

Provide better error message when you try to use a project command from outside a project #1829

Closed
antonymilne opened this issue Sep 5, 2022 · 0 comments · Fixed by #3680
Assignees
Labels
Component: CLI Issue/PR that addresses the CLI for Kedro Issue: Feature Request New feature or improvement to existing feature

Comments

@antonymilne
Copy link
Contributor

antonymilne commented Sep 5, 2022

Note. This ticket does not handle the question of what happens if you're in a subdirectory of the project. That is done in #1831 . This ticket is just about what happens if you're outside the project altogether (e.g. the level above the project).

When a kedro project command (e.g. kedro run) is run from outside a project then currently you get the very uninformative message run command is not found. We should change this so that it gives a much clearer message that you are outside a kedro project and should cd into the project before executing the command.

This has been started in #1720 @noklam . You could either continue working on that PR or start a new one. Relevant modifications to make:

  • since we're not interested in iterating upwards through parent directories here, the existing upwards iteration using find_project_root is no longer relevant. That leaves open the question of whether and how we might suggest what the correct kedro project directory is. It's definitely a bad idea to iterate downwards through directory structure arbitrarily deep (could take a long time). We could go one directory deep so long as it's not too expensive an operation (maybe need to check there aren't too many folders in the current directory first? Needs some quick time profiling to see). Or just not make any suggestion as to the right cd command.
  • if we're totally outside a kedro project, a helpful error message is great but:
    • is there some better way to check if the command is a project one without overriding get_command, e.g. check if it's in self.project_groups?
    • I don't think this formatting is "on brand" yet since we haven't moved the rest of the CLI to rich yet. Let's just do it as click.secho for now. Doing rich styling for CLI messages is a separate issue for another time (e.g. we might move to https://github.com/ewels/rich-click)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI Issue/PR that addresses the CLI for Kedro Issue: Feature Request New feature or improvement to existing feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants