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

--addons=all doesn't behave as expected #3334

Closed
merelcht opened this issue Nov 23, 2023 · 4 comments · Fixed by #3361
Closed

--addons=all doesn't behave as expected #3334

merelcht opened this issue Nov 23, 2023 · 4 comments · Fixed by #3361

Comments

@merelcht
Copy link
Member

merelcht commented Nov 23, 2023

Description

When I use --addons=all or --addons all in kedro new directly I don't get all addons as expected.
You can also see in the message:

You have selected the following add-ons:

Steps to Reproduce

  1. Checkout the develop branch
  2. Run kedro new --addons=all or kedro new --addons all
  3. Follow the rest of the prompts adding the name and example yes or no
  4. Check the resulting project
(dev) M-C02XN0V5JHD5:Testing merel_theisen$ kedro new --addons=all --example=yes --name=allbug

You have selected the following add-ons:

The project name 'allbug' has been applied to:
- The project title in /Users/merel_theisen/Projects/Testing/allbug/README.md
- The folder created for your project in /Users/merel_theisen/Projects/Testing/allbug
- The project's python package in /Users/merel_theisen/Projects/Testing/allbug/src/allbug

A best-practice setup includes initialising git and creating a virtual environment before running 'pip install -r requirements.txt' to install project-specific dependencies. Refer to the Kedro documentation: https://kedro.readthedocs.io/

Change directory to the project generated in /Users/merel_theisen/Projects/Testing/allbug by entering 'cd /Users/merel_theisen/Projects/Testing/allbug'

Expected Result

The resulting project should have tests folder and requirements for linting, testing and logging etc.

Actual Result

It doesn't have all the expected files and folder structures

❗ If I follow the prompts when doing kedro new and use all the project gets created as expected.

@merelcht
Copy link
Member Author

merelcht commented Nov 24, 2023

Should also test: kedro new --addons=lint,log,data,docs,test,viz,pyspark and why didn't the test pick this up?

@lrcouto
Copy link
Contributor

lrcouto commented Nov 28, 2023

Should also test: kedro new --addons=lint,log,data,docs,test,viz,pyspark and why didn't the test pick this up?

just tested it and it generates the files, the issue is happening only with the all option. Looking into it now.

@SajidAlamQB
Copy link
Contributor

SajidAlamQB commented Nov 28, 2023

I think I see the problem it might be in _convert_addon_names_to_numbers

def _convert_addon_names_to_numbers(selected_add_ons_flag: str | None) -> str | None:
"""Prepares add-on selection from the CLI input to the correct format
to be put in the project configuration, if it exists.
Replaces add-on strings with the corresponding prompt number.
Args:
selected_add_ons_flag: a string containing the value for the --addons flag,
or None in case the flag wasn't used, i.e. lint,docs.
Returns:
String with the numbers corresponding to the desired add_ons, or
None in case the --addons flag was not used.
"""
if selected_add_ons_flag is None:
return None
addons = []
for addon in selected_add_ons_flag.lower().split(","):
addon_short_name = addon.strip()
if addon_short_name in ADD_ONS_SHORTNAME_TO_NUMBER:
addons.append(ADD_ONS_SHORTNAME_TO_NUMBER[addon_short_name])
return ",".join(addons)

We don't have a check for the "all" flag. We should probably also have "none" check here as well as the None, confusing I know.

Something like this should fix it:

if selected_add_ons_flag.lower() == "all":
        return ",".join(ADD_ONS_SHORTNAME_TO_NUMBER.values())

PS @AhdraMeraliQB pointed out:

part of the reason the tests never picked this up is we never check if the add-ons related text is printed out, this would > probably go in assert_template_ok in test_starters.py

@SajidAlamQB
Copy link
Contributor

Completed in: #3361

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

Successfully merging a pull request may close this issue.

3 participants