-
Notifications
You must be signed in to change notification settings - Fork 926
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
Sort requirements.txt
based on package name only
#3436
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
851d4ba
Sort `requirements.txt` based on package name only
deepyaman b437bdf
Remove now-unused custom `requirements.txt` sorter
deepyaman 124685a
Ruff format kedro/templates/project/hooks/utils.py
deepyaman 4b718c9
Pass the right argument to `fix_requirements` call
deepyaman 895c41e
Add `sort_requirements` until starters are updated
deepyaman f9d1dec
Wrap lib call in existing method for compatibility
deepyaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
from pathlib import Path | ||
|
||
from kedro.templates.project.hooks.utils import ( | ||
|
||
setup_template_tools, | ||
sort_requirements, | ||
) | ||
from kedro.templates.project.hooks.utils import setup_template_tools, sort_requirements | ||
|
||
|
||
def main(): | ||
current_dir = Path.cwd() | ||
requirements_file_path = current_dir / "requirements.txt" | ||
pyproject_file_path = current_dir / "pyproject.toml" | ||
python_package_name = '{{ cookiecutter.python_package }}' | ||
python_package_name = "{{ cookiecutter.python_package }}" | ||
|
||
# Get the selected tools from cookiecutter | ||
selected_tools = "{{ cookiecutter.tools }}" | ||
example_pipeline = "{{ cookiecutter.example_pipeline }}" | ||
|
||
# Handle template directories and requirements according to selected tools | ||
setup_template_tools(selected_tools, requirements_file_path, pyproject_file_path, python_package_name, example_pipeline) | ||
setup_template_tools( | ||
selected_tools, | ||
requirements_file_path, | ||
pyproject_file_path, | ||
python_package_name, | ||
example_pipeline, | ||
) | ||
|
||
# Sort requirements.txt file in alphabetical order | ||
sort_requirements(requirements_file_path) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not extremely happy about adding a runtime dependency on
pre-commit-hooks
though. At least it's unconstrained, but (1) it's unclear to me if the project is meant to be used from its Python API (not that we're using a private function or anything, but I don't see references to it on the READMEs) and (2) this dependency only exists forkedro new
and users are already complaining that we have too many of them, this seems to go in the opposite direction.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@astrojuanlu If you feel strongly against it, I can just copy the implementation of that particular function. I added this because
pre-commit-hooks
is an extremely lightweight library (only dependency isruamel.yaml
, which itself is very light).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merelcht what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @astrojuanlu, this sort of dependency isn't core to Kedro as a Framework and so it doesn't belong as a run-time dependency. If anything it should be something like a "dev" dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merelcht I don't think that's @astrojuanlu's point. I am using
pre-commit-hooks
as a runtime dependency here, because the starter requirements get sorted.The question is whether to vendor the requirements sorting logic or leave this lightweight dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the blockers for Pyodide support #4278