Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions airflow/include/airflow3/exampledag.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"""

from airflow.sdk.definitions.asset import Asset
from airflow.decorators import dag, task
from airflow.sdk.types import RuntimeTaskInstanceProtocol
from airflow.sdk import dag, task
from pendulum import datetime
import requests

Expand All @@ -41,7 +42,7 @@ def example_astronauts():
# Define a dataset outlet for the task. This can be used to schedule downstream DAGs when this task has run.
outlets=[Asset("current_astronauts")]
) # Define that this task updates the `current_astronauts` Dataset
def get_astronauts(**context) -> list[dict]:
def get_astronauts(ti: RuntimeTaskInstanceProtocol) -> list[dict]:
"""
This task uses the requests library to retrieve a list of Astronauts
currently in space. The results are pushed to XCom with a specific key
Expand Down Expand Up @@ -71,9 +72,7 @@ def get_astronauts(**context) -> list[dict]:
{"craft": "Tiangong", "name": "Ye Guangfu"},
]

context["ti"].xcom_push(
key="number_of_people_in_space", value=number_of_people_in_space
)
ti.xcom_push(key="number_of_people_in_space", value=number_of_people_in_space)
return list_of_people_in_space

@task
Expand Down