Skip to content

[AIP-31] Create XComArg model #8052

@casassg

Description

@casassg

Description

XComArg is a class that references an XCom entry from an operator. Can be used to explicitly set XCom dependencies and explictly pass results between operators.

Class attributes:

  • operator: BaseOperator: Origin operator instance.
  • key: str: Stores key for XCom value. Defaults to airflow.models.xcom. XCOM_RETURN_KEY

Class methods

  • get(context: dict)-> Any: Resolves XCom value given operator and key.
  • __getitem__(key, str) -> XComArg: Easy method to create new XComArg using the same operator but a different key.
  • add_downstream_dependent(operator: BaseOperator)->None: Add an operator as a downstream dependency of operator. [Optional] Makes this task simpler.

Proposed implementation: https://github.com/casassg/corrent/blob/master/corrent/xcom_arg.py

Use case / motivation

  • Explicit way to pass around results between operators.
  • This object is a reference to an XCom value that has not been created and will need to be resolved in the future.
  • It can generate new XComArgs that point to the same operator but has a different key by using the key accessor. E.g: output['train'].
  • To do so, it includes as class attributes both the originating operator instance and a key (both needed to pull the XCom).
  • Has a property op that allows access to the origin operator.

Stretch goal

  • Store type class for the XCom and lie to MyPy when trying to check class signature.

Metadata

Metadata

Assignees

Labels

AIP-31Task Flow API for nicer DAG definitionkind:featureFeature Requests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions