-
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
allow using requirments.txt in PythonVirtualEnvOperator #16037
Comments
Can you see if you can pass |
How about this (I know it's not perfect, but I think it should do the job):
|
The requirements file format supports some things that can’t be passed into the command line, so the open-readline approach can only partially solve the issue. Making things worse, the file format is internal to pip, so there’s no way for the user to parse it on their own, the file must be passed into pip. So some way to support this would be nice. (I think I read another issue on this before…?) I believe |
Agree. Having a good, templated parameter could work. Now when I think obout it might actually be as simple as adding this to the operator and handling the case where
The |
Or maybe we can do something similar to |
I thinkl it the same feature we are talking about :). The "template_ext" works in the way that it will read the file as string when the parameter has the extension registered there and it will automatically process the file trough the template engine, so you can add jinja-variables from context /xcom variables in the file. It's built-in feature in BaseOperator All that you need is in this case to have the right extension (".txt") in the value of the parameter.
|
If the parameter is not string or does not have the extension it is processed as usual (i.e. passing list of strings will continue to work - but it will additionally process the strings through template engine (since "requirements" will be in "template_fields" tuple) so you could also add jinja variables in the strings in the array and they will be interpolated. |
But in this case you want the functionality of |
But this might be very useful. For example you can use jinja variable for version of a dependency and get it from another task. or have conditional requirements.txt content based on dev/prod settings etc. This is pretty useful feature IMHO. |
I think in your use case the whole requirement file is in fact not a requirement.txt but a value pushed to xcom by previous task. |
No. I am talking about "requirement.txt" file in which some values might be provided by XCom. I can imagine this kind of
|
ah cool!! |
I'd like to pick this (as part of the contributors-workshop) |
Hello @potiuk @alexInhert, I have tried an implementation of the above discussions, can you review once? Thanks. |
Co-authored-by: Tzu-ping Chung <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]>
Currently the operator allows to set requirement as list that needs to be hard coded.
It would be nice if airflow can support reading from file directly (something similar to how operators read sql file)
The text was updated successfully, but these errors were encountered: