The GitHub Actions job "Tests" on airflow.git has failed.
Run started by GitHub user kaxil (triggered by kaxil).

Head commit for run:
9627d5a1ff7e6785153d1cdf7fddd3a79311be65 / Kaxil Naik <[email protected]>
AIP-72: Add support for `get_current_context` in Task SDK

closes https://github.com/apache/airflow/issues/45234

I am putting the logic for `set_current_context` in 
`execution_time/context.py`. I didn't want to put `_CURRENT_CONTEXT` in 
`task_sdk/src/airflow/sdk/definitions/contextmanager.py` to avoid execution 
logic in a user-facing module but I couldn't think of another way to store it 
from execution & allow retrieving (via `get_current_context` in the Standard 
Provider) in their Task.

Upcoming PRs:
- Move most of the internal stuff in Task SDK to a separate module.
- Use `create_runtime_ti` fixture more widely in tests

---

Tested with the following DAG:

```py
import pendulum

from airflow.decorators import dag, task
from airflow.providers.standard.operators.python import get_current_context

@dag(
    schedule=None,
    start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
    catchup=False,
)
def x_get_context():
    @task
    def template_test(data_interval_end):
        context = get_current_context()

        # Will print `2024-10-10 00:00:00+00:00`.
        # Note how we didn't pass this value when calling the task. Instead
        # it was passed by the decorator from the context
        print(f"data_interval_end: {data_interval_end}")

        # Will print the full context dict
        print(f"context: {context}")

    template_test()

x_get_context()

```
<img width="1703" alt="image" 
src="https://github.com/user-attachments/assets/2763963a-d299-412f-bee3-3b20904ca7c8";
 />

Report URL: https://github.com/apache/airflow/actions/runs/12678289232

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to