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

Use cookiecutter hooks to strip-out not selected "add-ons" from base template #2837

Closed
merelcht opened this issue Jul 25, 2023 · 3 comments
Closed
Assignees

Comments

@merelcht
Copy link
Member

merelcht commented Jul 25, 2023

Description

Follow up on #2758

Context

Depending on the utilities/add-ons a user selects from the following:

  1. testing
  2. linting
  3. logging
  4. data structure
  5. documentation

We need to add in certain directories/files in a new project when the user executes kedro new without starter.

Proposed Implementation

Use cookiecutter hooks to remove and update files/directories depending on the add-ons selection: https://cookiecutter.readthedocs.io/en/stable/advanced/hooks.html#example-conditional-files-directories

  • Remove /tests and update requirements.txt and pyproject.toml if testing is not selected
  • Remove setup.cfg (might already be gone by the time this ticket is taken up) and update requirements.txt and pyproject.toml if linting is not selected
  • Remove logging.yml if logging is not selected
  • Remove /data if data structure is not selected
  • Remove /docs and update setup.py if documentation is not selected
@SajidAlamQB
Copy link
Contributor

SajidAlamQB commented Sep 6, 2023

I had some thoughts on some approaches we could take for this issue which is being done in #2987. Specifically to handle the dependencies in requirements.txt and pyproject.toml in our template. I would love to get any feedback/opinions on them:

Approach A (Reactive):

Start with a requirements.txt and pyproject.toml that includes dependencies for all add-ons by default as we do now.
The post-generation hook script will then remove the dependencies for the add-ons that the user didn't select.

Adv:

  • Easier to manage if we only occasionally add or remove add-ons.

Cons:

  • More likely have errors as if the files change somehow in the future, the script might fail or introduce weird errors.

Approach B (Proactive):

Start with a barebones requirements.txt and pyproject.toml that only contain the essential dependencies.
The post-generation hook script will append necessary dependencies based on the add-ons the user selects.

Adv:

  • Less error-prone since we're adding known dependencies rather than trying to remove potentially unknown ones.
  • Keeps the base files clean and simple.

Cons:

  • If we frequently add/change dependencies the script might also have to be updated frequently (More burden?).

Which approach do you think is more better for our needs? I am inclined to Approach B but also open to hear everyone's thoughts or opinions. @merelcht @lrcouto @noklam @astrojuanlu @amandakys

PS, maybe an even more radical idea we have separate dependency files for each add-on: e.g., requirements-linting.txt, requirements-testing.txt, etc and we use the hook script to concatenate the selected add-on dependency files into the main requirements.txt post-generation.

PPS, This opens up to a larger question what should the default add-ons case be, in #2987, I've set it to none, no add-ons included, but it this the right way?

@merelcht
Copy link
Member Author

merelcht commented Sep 7, 2023

I'm also in favour of approach B as it's the most adaptable if we want to allow users to add plugins later in their project journey and not only in the project creation flow.

PPS, This opens up to a larger question what should the default add-ons case be, in #2987, I've set it to none, no add-ons included, but it this the right way?

IMO, that is indeed the right way. Since we're calling this the "add-ons" flow to me it makes the most sense that you start with nothing and add on what you need, so that means a default of none.

@AhdraMeraliQB AhdraMeraliQB self-assigned this Sep 8, 2023
@AhdraMeraliQB AhdraMeraliQB moved this from In Progress to In Review in Kedro Framework Sep 19, 2023
@AhdraMeraliQB AhdraMeraliQB moved this from In Review to Done in Kedro Framework Oct 10, 2023
@AhdraMeraliQB
Copy link
Contributor

Closed by #2987

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

No branches or pull requests

4 participants