-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Preserve all context keys during serialization #50446
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
Preserve all context keys during serialization #50446
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
potiuk
left a comment
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.
Nice one - however, maybe instead of regexp you should parse the requirement with packaging requirements and take name of distribution from there: https://packaging.pypa.io/en/stable/requirements.html
This has additional advantage of actually parsing the requirements and will fail early in case any of the requirements are not following the specification.
931cc1b to
d974c4b
Compare
|
Hello @potiuk, thank you for the suggestion. I modified the code to use |
d974c4b to
451914c
Compare
451914c to
1794d68
Compare
providers/standard/src/airflow/providers/standard/operators/python.py
Outdated
Show resolved
Hide resolved
potiuk
left a comment
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.
Nice! One, very small nit. Good points with comment removals.
When instantiating a PythonVirtualenvOperator (or subclass), part of the
context is propagated based on the requirements constructor parameter.
The current implementation only adds the 'pendulum' and 'apache-airflow'
context keys for bare package names.
For instance:
* requirements=["pendulum"] -> works
* requirements=["pendulum<3.0"] -> does not work
This change uses 'packaging.requirements' to ensure all version
specifiers are handled correctly.
1794d68 to
857d2cb
Compare
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
| # invalid version format | ||
| "pendulum==3..0", | ||
| # invalid operator (=< instead of <=) | ||
| "apache-airflow=<2.0", | ||
| # same invalid operator on pendulum | ||
| "pendulum=<3.0", | ||
| # totally malformed | ||
| "invalid requirement", |
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.
We do not account for the case when more than one are passed.
Follow-up to apache#50446 and apache#50521: - Clean up requirements-flattening logic. - Add tests for requirements passed as multi-line strings.
Follow-up to apache#50446 and apache#50521: - Clean up requirements-flattening logic. - Add tests for requirements passed as multi-line strings.
Follow-up to apache#50446 and apache#50521: - Clean up requirements-flattening logic. - Add tests for requirements passed as multi-line strings.
Follow-up to apache#50446 and apache#50521: - Clean up requirements-flattening logic. - Add tests for requirements passed as multi-line strings.
Follow-up to apache#50446 and apache#50521: - Clean up requirements-flattening logic. - Add tests for requirements passed as multi-line strings.
When instantiating a PythonVirtualenvOperator (or subclass), part of the
context is propagated based on the requirements constructor parameter.
The current implementation only adds the 'pendulum' and 'apache-airflow'
context keys for bare package names.
For instance:
* requirements=["pendulum"] -> works
* requirements=["pendulum<3.0"] -> does not work
This change uses 'packaging.requirements' to ensure all version
specifiers are handled correctly.
Follow-up to apache#50446 and apache#50521: - Clean up requirements-flattening logic. - Add tests for requirements passed as multi-line strings.
When instantiating a PythonVirtualenvOperator, part of the context is propagated based on the requirements constructor parameter. The current logic implementation prevents 'pendulum' or 'apache-airflow' keys to be added to the Airflow context as soon as a version specifier is used.
For instance this requirement list will have the expected behavior:
Whereas this one will cause the
pendulumobjects to be stripped out of the context:This PR aims to fix these limitations.