[AIP-31] Create XComArg model
See original GitHub issueDescription
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 toairflow.models.xcom. XCOM_RETURN_KEY
Class methods
get(context: dict)-> Any
: Resolves XCom value givenoperator
andkey
.__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 ofoperator
. [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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:15 (14 by maintainers)
Top Results From Across the Web
airflow.models.xcom_arg — Airflow Documentation
This is used to determine how many task instances the scheduler should create for a downstream using this XComArg for task-mapping.
Read more >Airflow 2.0: DAG Authoring Redesigned
TaskFlow API (AIP-31). The first significant change is the introduction of TaskFlow API. This new thing consists of three features: XComArg — a...
Read more >July 10, 2020
AIP-31 : Airflow functional ... Ex: model training metrics. ... BaseOperator property to generate default XComArg: .output.
Read more >Streamline Pipeline Code with Functional DAGs in Airflow 2.0
Here is Databand's intro to AIP-31, a guide for data engineers on how ... for quickly creating complex pipelines with many chains of...
Read more >[AIRFLOW-8057] [AIP-31] Add @task decorator
_called = True + return XComArg(self) + + def copy(self, task_id: Optional[str] = None, **kwargs): + """ + Create a copy of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey guys, the databand team and I decided to implement [AIP-31] starting tomorrow. Will be in touch with you soon for implementation discussions. Thanks, Johnny 😃
it’s definitely an option for people who wants a “purely function” approach from the beginning. Most of Airflow users are already very invested in the current implementation without functional operators.
IMHO: ( as I wrote at current PR), we should decide before we push implementation into Airflow/master and we should base our decision on some examples we wrote with end to end usage of AIP-31 implementation. I see a point in keeping everything as simple as possible, at the same time, I want all users to be happy if it doesn’t affect implementation in a bad way 😃