-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
#16037 Templated requirements.txt in Python operators #17349
#16037 Templated requirements.txt in Python operators #17349
Conversation
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
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 think we need to support "prepare_virtualenv" backwards compatible behaviour.
airflow/utils/python_virtualenv.py
Outdated
@@ -87,14 +87,15 @@ def prepare_virtualenv( | |||
:param system_site_packages: Whether to include system_site_packages in your virtualenv. | |||
See virtualenv documentation for more information. | |||
:type system_site_packages: bool | |||
:param requirements: List of additional python packages | |||
:type requirements: List[str] | |||
:param requirements: Path to the requirements.txt file |
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 think we should still (backwards compatibility) handle the case where requirements are List[str]. It will make it a bit more complex, but I think it is needed.
I propose to keep the old requrements
handling only List[str] and add a new parameter requirements_file_path
- and check if only one of those is passed (and act accordingly). I think it is very ambiguous to name requirements
something that is path to requirements file.
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.
Addressed! 😃
Come on CI |
Looks like one of the tests is stuck, shall I push an empty commit @uranusjr ? |
No need, I just re-triggered them. |
One check is failing where |
I think you need to rebase - that was celery-5 change that got merged recently, and it is conflcting unless you rebase to latest |
4c01b64
to
80322bd
Compare
tests are failing:
|
This module is a part of setuptools, and not guaranteed to be installed into a new virtual environment. Fortunately funcsigs exposes the __version__ attribute at top level, so we don't really need to read package metadata to test it.
Those |
e2d2abf
to
cf53aa7
Compare
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 committed and pushed the previous review suggestions directly to the branch.
Awesome work, congrats on your first merged pull request! |
This does not seem to be working properly when
In this line, the airflow/airflow/operators/python.py Line 399 in b597cea
Then, this file path is put into the airflow/airflow/operators/python.py Line 423 in b597cea
Next, this file path (rather than its contents) is written to the airflow/airflow/operators/python.py Line 429 in b597cea
Indeed, if I pass it I think it would be best to change airflow/airflow/operators/python.py Line 399 in b597cea
to
|
A pull request would be much appreciated. |
See PR #24368 |
Closes: #16037
This pull request addresses the changes discussed in the aforementioned issue.
Changes:
requirements.txt
file in therequirements
field of the PythonVirtualenvOperator.*.txt
(anything ending with .txt), and can be jinja templated.Note:
template_searchpath
must be appropriately set while using arbitrary locations of the template file.