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

Change to short names in config #3499

Merged
merged 12 commits into from
Jan 18, 2024
Merged

Change to short names in config #3499

merged 12 commits into from
Jan 18, 2024

Conversation

DimedS
Copy link
Contributor

@DimedS DimedS commented Jan 10, 2024

Description

This PR addresses Issue 4 from #3335, implementing the following changes:

  1. Altered the tools format derived from the config file to use short names instead of numbers.
  2. Updated both unit and E2E tests to reflect these changes. Combined test_tools_flag_none() with test_valid_tools_flag() as the only difference between them is a single line.
  3. Updated or added missing comments to ensure they are current.
  4. Consolidated the functions for fetching, validating, and parsing the configuration from a file into a single function.
  5. Modified the _convert_tool_names_to_numbers() function to return a list directly instead of string, eliminating the need for additional processing. The _parse_tools_input() function was utilized for this purpose.
  6. Restructured the _get_extra_context() function for enhanced clarity. It's divided into distinct sections, with a specific section for default values.
  7. Improved the _validate_range(start, end) function, which checks the range interval of tools. Previously, entering an excessively large end value would cause the prompt to freeze. An additional check for the upper limit of the range has been introduced to prevent this issue.

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

@DimedS DimedS linked an issue Jan 10, 2024 that may be closed by this pull request
@DimedS DimedS marked this pull request as ready for review January 11, 2024 09:59
@DimedS DimedS requested a review from merelcht as a code owner January 11, 2024 09:59
Copy link
Contributor

@ankatiyar ankatiyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually tested, works well! Thanks @DimedS!

Copy link
Contributor

@AhdraMeraliQB AhdraMeraliQB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the tools docs pages too within this PR?

Additionally don't forget to put these changes in RELEASE.md with a note about them breaking tools config

Copy link
Member

@merelcht merelcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is starting to look a lot better with these refactorings, but I think there's still a bit more we can do. I've left comments with some suggestions.

features/steps/cli_steps.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
@DimedS DimedS force-pushed the 3335-use-short-names-in-config branch from d8d66e7 to 829d048 Compare January 12, 2024 18:22
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
@DimedS
Copy link
Contributor Author

DimedS commented Jan 14, 2024

Could you update the tools docs pages too within this PR?

Additionally don't forget to put these changes in RELEASE.md with a note about them breaking tools config

thank you for the links @AhdraMeraliQB , fixed

@DimedS
Copy link
Contributor Author

DimedS commented Jan 14, 2024

The code is starting to look a lot better with these refactorings, but I think there's still a bit more we can do. I've left comments with some suggestions.

Thank you, @merelcht , for your valuable suggestions. I've implemented them and they indeed make a lot of sense.

Could you help me understand the purpose of the test_fetch_config_from_user_prompts_with_context() function? I've temporarily removed it as I'm unsure how to modify it after updating the fetch_config_from_user_prompts() function. Your guidance on this would be greatly appreciated.

@merelcht
Copy link
Member

Thank you, @merelcht , for your valuable suggestions. I've implemented them and they indeed make a lot of sense.

Could you help me understand the purpose of the test_fetch_config_from_user_prompts_with_context() function? I've temporarily removed it as I'm unsure how to modify it after updating the fetch_config_from_user_prompts() function. Your guidance on this would be greatly appreciated.

I added that test to cover these lines:

if not cookiecutter_context:
raise Exception("No cookiecutter context available.")

Test coverage seems to be fine though, so I guess it might be tested in another way now and test_fetch_config_from_user_prompts_with_context isn't needed anymore.

kedro/framework/cli/starters.py Show resolved Hide resolved
)
# set defaults for required fields, will be used mostly for starters
extra_context.setdefault("kedro_version", version)
extra_context.setdefault("tools", str(["None"]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str(["None"]) still seems like a bit of an odd value to me.. We don't have to change that in this PR, but I think it would be good to discuss.

Copy link
Contributor Author

@DimedS DimedS Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea, just noting this here but not adding to the scope of the PR - could we save it as an unwrapped list ["None"] instead?

Context:

The reason we pass through a list wrapped in a string is because cookiecutter interprets a list as a provision of options, from which it selects one to save. To preserve all the chosen tools, we wrap the list in a string. Though the option for no tools is processed separately, pyproject.toml has no knowledge of what is passed through and so we cannot pass through just the string "None" (which will be unwrapped).

However, none tools cannot be selected with any other tools, and so passing through just a list shouldn't have any adverse effects; cookiecutter would pick the only option from the list - "None" - and pass that through to pyproject.toml.

Would we run into the same problem with unwrapping strings? If so we could always pass through [["None"]] but it doesn't seem much better than str(["None"]) 🤔

Additionally, for telemetry, should we be consistent with what we store (a list for several tools, but this would save a string if no tools are selected)?

Alternatively, I believe using dictionaries to pass a collection of objects through cookiecutter is possible, but it would require significant changes to pyproject.toml - I'm unsure we'd be able to preserve the list type as we'd have to somehow process these values within the cookiecutter execution.

Any opinions on this? CC: @DimedS @merelcht

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhdraMeraliQB , and why we need a string of a list? Why just a string is not enough, like:
tools = "Linting, Testing, ..." or tools = "None"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DimedS
If I remember correctly, the reason is tied to telemetry - it's easier (and more intuitive) to query tools data when stored as a list than as a string. We did originally pass this through as a string (xref), but was suggested to be changed as part of #3264 and in #3333

The fix in #3426 introduced using str["None"] to workaround cookiecutter limitations (see Nok's comment) and the rest is history 😅

Copy link
Contributor

@AhdraMeraliQB AhdraMeraliQB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving my comments on the implementation here, they affect some of the choices made in test_starters.py so I'll wait to resolve these before continuing the review of that file

features/steps/cli_steps.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Show resolved Hide resolved
kedro/framework/cli/starters.py Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
DimedS and others added 2 commits January 17, 2024 11:55
Signed-off-by: Dmitry Sorokin <40151847+DimedS@users.noreply.github.com>
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
Copy link
Contributor

@AhdraMeraliQB AhdraMeraliQB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks amazing!! Thank you for all the changes - only one significant question (re: the error messages) from me 😄

kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
tests/framework/cli/test_starters.py Outdated Show resolved Hide resolved
tests/framework/cli/test_starters.py Show resolved Hide resolved
tests/framework/cli/test_starters.py Outdated Show resolved Hide resolved
tests/framework/cli/test_starters.py Show resolved Hide resolved
tests/framework/cli/test_starters.py Show resolved Hide resolved
DimedS and others added 4 commits January 17, 2024 17:45
Co-authored-by: Ahdra Merali <90615669+AhdraMeraliQB@users.noreply.github.com>
Signed-off-by: Dmitry Sorokin <40151847+DimedS@users.noreply.github.com>
Signed-off-by: Dmitry Sorokin <40151847+DimedS@users.noreply.github.com>
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com>
Copy link
Contributor

@AhdraMeraliQB AhdraMeraliQB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work @DimedS!! Thanks for making all the changes, this will make the file so much easier to read 🌟

The PR has changed quite a bit since the first approval, I've re-requested @ankatiyar to take a new look at this before we give it the final send-off 🚀

Copy link
Contributor

@ankatiyar ankatiyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @DimedS for the fix as well as a refactoring! 👍🏾

@DimedS
Copy link
Contributor Author

DimedS commented Jan 18, 2024

Thank you for your contribution @AhdraMeraliQB , @ankatiyar , @merelcht !

@DimedS DimedS merged commit d6a78f4 into main Jan 18, 2024
34 checks passed
@DimedS DimedS deleted the 3335-use-short-names-in-config branch January 18, 2024 15:05
@DimedS DimedS mentioned this pull request Jan 19, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency in kedro new with --config
4 participants