Skip to content

Pass "real" TaskInstance object with xcom methods in context to task execute functions #44481

Closed

Activity

  1. converted this from a draft issue on Nov 29, 2024
  2. self-assigned this
    on Nov 29, 2024
  3. assigned and unassigned on Dec 3, 2024
  4. moved this from Next 2 Weeks to In Progress in AIP-72 - Task Execution Interface and SDKon Dec 3, 2024
  5. kaxil commented on Dec 10, 2024

    @kaxil
    Member

    The current values in the Context dict:

    • # NOTE: If you add to this dict, make sure to also update the following:
      # * Context in airflow/utils/context.pyi
      # * KNOWN_CONTEXT_KEYS in airflow/utils/context.py
      # * Table in docs/apache-airflow/templates-ref.rst
      context: dict[str, Any] = {
      "conf": conf,
      "dag": dag,
      "dag_run": dag_run,
      "data_interval_end": timezone.coerce_datetime(data_interval.end),
      "data_interval_start": timezone.coerce_datetime(data_interval.start),
      "outlet_events": OutletEventAccessors(),
      "ds": ds,
      "ds_nodash": ds_nodash,
      "expanded_ti_count": expanded_ti_count,
      "inlets": task.inlets,
      "inlet_events": InletEventsAccessors(task.inlets, session=session),
      "logical_date": logical_date,
      "macros": macros,
      "map_index_template": task.map_index_template,
      "outlets": task.outlets,
      "params": validated_params,
      "prev_data_interval_start_success": get_prev_data_interval_start_success(),
      "prev_data_interval_end_success": get_prev_data_interval_end_success(),
      "prev_start_date_success": get_prev_start_date_success(),
      "prev_end_date_success": get_prev_end_date_success(),
      "run_id": task_instance.run_id,
      "task": task,
      "task_instance": task_instance,
      "task_instance_key_str": f"{task.dag_id}__{task.task_id}__{ds_nodash}",
      "test_mode": task_instance.test_mode,
      "ti": task_instance,
      "triggering_asset_events": lazy_object_proxy.Proxy(get_triggering_events),
      "ts": ts,
      "ts_nodash": ts_nodash,
      "ts_nodash_with_tz": ts_nodash_with_tz,
      "var": {
      "json": VariableAccessor(deserialize_json=True),
      "value": VariableAccessor(deserialize_json=False),
      },
      "conn": ConnectionAccessor(),
    • Template ref: https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html

    The plan is to:

    • Get certain key:value pairs from the API Server and pass it as a response to start the request to the API server (with TIEnterRunningPayload)
    • Augment it with key:value pairs from the Task Execution Interface (execution side of the Task SDK)

    As a goal: I am planning to get as much info as possible on the Execution side itself as opposed to getting it from the API server

  6. 70 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions