GitHub user nehemias-bedrockanalytics edited a comment on the discussion: 
Accessing TaskInstances from DagRun context after Airflow 3.x API changes

Not sure what is the right way but looking at 
[RuntimeTaskInstance](https://github.com/apache/airflow/blob/main/task-sdk/src/airflow/sdk/execution_time/task_runner.py#L502)
 implementation I see how communication with the Supervisor is made though the 
`SUPERVISOR_COMMS` object, which seems to have a list of things it can do, of 
which 
[GetTaskStates](https://github.com/apache/airflow/blob/main/task-sdk/src/airflow/sdk/execution_time/comms.py#L877)
 is one of them.

comms.py has a list of the available actions we can take, I don't see one to 
get task instances, I see another useful one to me, TriggerDagRun.

This would be a way to trigger a dag run:

```python
from datetime import datetime, timezone
from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
from airflow.sdk.execution_time.comms import TriggerDagRun

trigger = TriggerDagRun(dag_id="my_dag", 
                  run_id="my_dag_run_001", 
                  logical_date=datetime.now(timezone.utc),
                  conf={})

response = SUPERVISOR_COMMS.send(msg=trigger)
```

response will be something like

```
OKResponse(ok=True, type='OKResponse')
```

Still want to know how to get task instances properly in Airflow 3

GitHub link: 
https://github.com/apache/airflow/discussions/56037#discussioncomment-14824639

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to