airflow.models.xcom
¶
Module Contents¶
Classes¶
Base class for XCom objects. |
|
Wrapper to lazily pull XCom with a sequence-like interface. |
Functions¶
Resolves custom XCom class |
Attributes¶
- class airflow.models.xcom.BaseXCom(context=None)[source]¶
Bases:
airflow.models.base.Base
,airflow.utils.log.logging_mixin.LoggingMixin
Base class for XCom objects.
- init_on_load()[source]¶
Called by the ORM after the instance has been loaded from the DB or otherwise reconstituted i.e automatically deserialize Xcom value when loading from DB.
- classmethod get_value(*, ti_key, key=None, session=NEW_SESSION)[source]¶
Retrieve an XCom value for a task instance.
This method returns “full” XCom values (i.e. uses
deserialize_value
from the XCom backend). Useget_many()
if you want the “shortened” value viaorm_deserialize_value
.If there are no results, None is returned. If multiple XCom entries match the criteria, an arbitrary one is returned.
- Parameters
ti_key (airflow.models.taskinstance.TaskInstanceKey) – The TaskInstanceKey to look up the XCom for.
key (str | None) – A key for the XCom. If provided, only XCom with matching keys will be returned. Pass None (default) to remove the filter.
session (sqlalchemy.orm.Session) – Database session. If not given, a new session will be created for this function.
- static serialize_value(value, *, key=None, task_id=None, dag_id=None, run_id=None, map_index=None)[source]¶
Serialize XCom value to str or pickled object.
- orm_deserialize_value()[source]¶
Deserialize method which is used to reconstruct ORM XCom object.
This method should be overridden in custom XCom backends to avoid unnecessary request or other resource consuming operations when creating XCom orm model. This is used when viewing XCom listing in the webserver, for example.
- class airflow.models.xcom.LazyXComAccess[source]¶
Bases:
collections.abc.Sequence
Wrapper to lazily pull XCom with a sequence-like interface.
Note that since the session bound to the parent query may have died when we actually access the sequence’s content, we must create a new session for every function call with
with_session()
.