bryzgaloff commented on issue #20974:
URL: https://github.com/apache/airflow/issues/20974#issuecomment-1580466411
**As a quick workaround**, instead of passing `**context` as a whole, **you
may pass its entries as individual function arguments using Jinja2 templates**.
I also had a problem with a `python_callable` function pickling when passing
`**` both with and without `system_site_packages`, and here is an example of
how I did it for `data_interval_start`:
```python
@task.virtualenv(requirements='…')
def add_days(
data_interval_start_str: str,
days_to_add: int, # just an example of a "regular" arg
) -> str:
from datetime import datetime
return
datetime.fromisoformat(data_interval_start_str).add(days=days_to_add).isoformat()
with dag:
add_days(
'{{ data_interval_start.isoformat() }}', # falling back to jinja
templating
10, # days to add
) >> OtherOperator(…)
```
I believe this workaround is applicable for a majority of cases: **you may
serialize everything to string first using Jinja, then deserialize it inside
the function**.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]