Open oriolcmp opened 3 years ago
Thanks for opening your first issue here! Be sure to follow the issue template!
Hello,
Do you have any news on this issue? It would be very useful for us to use it. Thanks,
oriol
I have un-assigned myself so it is up for grabs :)
Sharing a few notes as I've run into this same issue:
PythonVirtualenvOperator
address this:
You can use the op_args and op_kwargs arguments the same way you use it in the PythonOperator. Unfortunately we currently do not support to serialize var and ti / task_instance due to incompatibilities with the underlying library.
PythonVirtualenvOperator
there is https://github.com/apache/airflow/issues/7870 which addresses using dill
vs. cloudpickle
(but doesn't mention how/if this would enable serialization of ti
, etc.). Anyone have any insight if https://github.com/apache/airflow/issues/7870 is a pre-req to this current issue?I thought provide_context was removed from Python operators in Airflow 2?
It was, and what provide_context
provides is now generally always available. So this issue (in 2.0) is more about there is no way to expose ti
to the callable run by a PythonVirtualenvOperator
.
Also found this Jira story (https://issues.apache.org/jira/browse/AIRFLOW-2738) that's still open that seems to be addressing the same problem.
Just a quick note: the community has migrated the issues tracking system from Jira to GitHub issues, so whatever left in Jira right now is likely outdated or inaccurate.
Sound like a feature to add rather than bug-fix I am moving it to 2.2 milestone.
Sorry but I don't think it shouldn't be a feature. It is a bug because If I'm not wrong all operators should be able to use XCom variables. And with this operator currently this is not possible. This operator could be very useful to deal with dependency contraints but without passing variables is kind of limited and it seems the only option left is to use DockerOperator.
Hello,
After two years with this ticket open and after adding a fix like #19616 which seems was the same issue but in this case adding the "ti" as serializable would have fixed this ticket. I'm wondering which solution I'm suppose to use if I want to run dags with several python operators but avoid having a requirements file for all Dags? I'm thinking about DockerOperator as the only alternative solution but I thought PythonVirtualenvOperator was a simpler solution. However, nobody seems to be worried for the fact that it is currently not possible to use XCOMS with PythonVirtualenvOperator. Could you give me some hints on that? Thanks
Feel free to propose a PR to add ti
to the list.
@oriolcmp - it works here in the way that the fastest way to implement somethign that you really want to, is to implement it. I think waiting two years for something you want is far too long, but if no-one picked it up, then indeed implementing by you is way better.
Are you going to solve this problem? It seems to be still relevant and it's very sad that such an important feature like XCom is not available in PythonVirtualenvOperator
Apache Airflow version: 1.10.13
Environment: Docker (Ubuntu 18.4 - Python 3.7)
What happened:
When we enable provide_context=True for PythonVirtualenvOperator and try to use the xcom_push to pass a variable I get this error:
File "/tmp/venv0upgqome/script.py", line 13, in push\n kwargs[\'ti\'].xcom_push(key=\'value from pusher 1\', value=value_1)\nKeyError: \'ti\'\n'
How to reproduce it: