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

Unhide cookiecutter errors in kedro new #2564

Closed
astrojuanlu opened this issue May 5, 2023 · 0 comments · Fixed by #3693
Closed

Unhide cookiecutter errors in kedro new #2564

astrojuanlu opened this issue May 5, 2023 · 0 comments · Fixed by #3693
Assignees
Labels
Issue: Feature Request New feature or improvement to existing feature

Comments

@astrojuanlu
Copy link
Member

Description

Somehow the opposite of gh-2401: when cookiecutter fails, kedro new prompts you to re-run with --verbose:

> kedro new --starter=spaceflights

Project Name
============
Please enter a human readable name for your new project.
Spaces, hyphens, and underscores are allowed.
 [Spaceflights]: 
kedro.framework.cli.utils.KedroCliError: Failed to generate project when running cookiecutter.
Run with --verbose to see the full exception
Error: Failed to generate project when running cookiecutter.

Context

In my case, the issue was quite silly: the directory already existed.

> kedro new --starter=spaceflights --verbose

Project Name
============
Please enter a human readable name for your new project.
Spaces, hyphens, and underscores are allowed.
 [Spaceflights]: 
Traceback (most recent call last):
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/kedro/framework/cli/starters.py", line 351, in _create_project
    result_path = cookiecutter(template=template_path, **cookiecutter_args)
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/cookiecutter/main.py", line 114, in cookiecutter
    result = generate_files(
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/cookiecutter/generate.py", line 291, in generate_files
    project_dir, output_directory_created = render_and_create_dir(
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/cookiecutter/generate.py", line 223, in render_and_create_dir
    raise OutputDirExistsException(msg)
cookiecutter.exceptions.OutputDirExistsException: Error: "/private/tmp/spaceflights" directory already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/kedro/framework/cli/starters.py", line 233, in new
    _create_project(template_path, cookiecutter_args)
  File "/Users/juan_cano/.micromamba/envs/_test310/lib/python3.10/site-packages/kedro/framework/cli/starters.py", line 353, in _create_project
    raise KedroCliError(
kedro.framework.cli.utils.KedroCliError: Failed to generate project when running cookiecutter.
Error: Failed to generate project when running cookiecutter.

Possible Implementation

Capture the error and show it. Something like this:

> kedro new --starter=spaceflights --verbose                                                                                                                                (_test310) 

Project Name
============
Please enter a human readable name for your new project.
Spaces, hyphens, and underscores are allowed.
 [Spaceflights]: 
cookiecutter.exceptions.OutputDirExistsException: Error: "/private/tmp/spaceflights" directory already exists
Run with --verbose to see the full exception
Error: Failed to generate project when running cookiecutter.

Possible Alternatives

Just display the full traceback on error. But I don't think it's optimal in its current form, since the actual error is hidden in the middle.

@astrojuanlu astrojuanlu added the Issue: Feature Request New feature or improvement to existing feature label May 5, 2023
@merelcht merelcht changed the title Unhide cookiecutter errors by default? Unhide cookiecutter errors in kedro new May 22, 2023
@merelcht merelcht added this to the Improve Kedro CLI milestone May 22, 2023
@noklam noklam moved this to To Do in Kedro Framework Mar 4, 2024
@ElenaKhaustova ElenaKhaustova self-assigned this Mar 8, 2024
@ElenaKhaustova ElenaKhaustova moved this from To Do to In Progress in Kedro Framework Mar 8, 2024
@ElenaKhaustova ElenaKhaustova moved this from In Progress to In Review in Kedro Framework Mar 12, 2024
@github-project-automation github-project-automation bot moved this from In Review to Done in Kedro Framework Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Feature Request New feature or improvement to existing feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants