airflow.models.xcom

Module Contents

Classes

BaseXCom

Base class for XCom objects.

Functions

resolve_xcom_backend()

Resolve custom XCom class.

Attributes

log

XCom

airflow.models.xcom.log[source]
class airflow.models.xcom.BaseXCom(context=None)[source]

Bases: airflow.models.base.Base, airflow.utils.log.logging_mixin.LoggingMixin

Base class for XCom objects.

__tablename__ = 'xcom'[source]
dag_run_id[source]
task_id[source]
map_index[source]
key[source]
dag_id[source]
run_id[source]
value[source]
timestamp[source]
__table_args__ = ()[source]
dag_run[source]
execution_date[source]
init_on_load()[source]

Execute after the instance has been loaded from the DB or otherwise reconstituted; called by the ORM.

i.e automatically deserialize Xcom value when loading from DB.

__repr__()[source]

Return repr(self).

static 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). Use get_many() if you want the “shortened” value via orm_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.taskinstancekey.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.

classmethod delete(xcoms, session)[source]

Delete one or multiple XCom entries.

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.

static deserialize_value(result)[source]

Deserialize XCom value from str or pickle 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.

airflow.models.xcom.resolve_xcom_backend()[source]

Resolve custom XCom class.

Confirm that custom XCom class extends the BaseXCom. Compare the function signature of the custom XCom serialize_value to the base XCom serialize_value.

airflow.models.xcom.XCom[source]

Was this entry helpful?