airflow.models.xcom

Module Contents

airflow.models.xcom.log[source]
airflow.models.xcom.MAX_XCOM_SIZE = 49344[source]
airflow.models.xcom.XCOM_RETURN_KEY = return_value[source]
class airflow.models.xcom.BaseXCom[source]

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

Base class for XCom objects.

__tablename__ = xcom[source]
key[source]
value[source]
timestamp[source]
execution_date[source]
task_id[source]
dag_id[source]
init_on_load(self)[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.

__repr__(self)[source]
classmethod set(cls, key, value, execution_date, task_id, dag_id, session=None)[source]

Store an XCom value.

Returns

None

classmethod get_one(cls, execution_date: pendulum.DateTime, key: Optional[str] = None, task_id: Optional[Union[str, Iterable[str]]] = None, dag_id: Optional[Union[str, Iterable[str]]] = None, include_prior_dates: bool = False, session: Session = None)[source]

Retrieve an XCom value, optionally meeting certain criteria. Returns None of there are no results.

Parameters
  • execution_date (pendulum.datetime) – Execution date for the task

  • key (str) – A key for the XCom. If provided, only XComs with matching keys will be returned. To remove the filter, pass key=None.

  • task_id (str) – Only XComs from task with matching id will be pulled. Can pass None to remove the filter.

  • dag_id (str) – If provided, only pulls XCom from this DAG. If None (default), the DAG of the calling task is used.

  • include_prior_dates (bool) – If False, only XCom from the current execution_date are returned. If True, XCom from previous dates are returned as well.

  • session (sqlalchemy.orm.session.Session) – database session

classmethod get_many(cls, execution_date: pendulum.DateTime, key: Optional[str] = None, task_ids: Optional[Union[str, Iterable[str]]] = None, dag_ids: Optional[Union[str, Iterable[str]]] = None, include_prior_dates: bool = False, limit: Optional[int] = None, session: Session = None)[source]

Composes a query to get one or more values from the xcom table.

Parameters
  • execution_date (pendulum.datetime) – Execution date for the task

  • key (str) – A key for the XCom. If provided, only XComs with matching keys will be returned. To remove the filter, pass key=None.

  • task_ids (str or iterable of strings (representing task_ids)) – Only XComs from tasks with matching ids will be pulled. Can pass None to remove the filter.

  • dag_ids (str) – If provided, only pulls XComs from this DAG. If None (default), the DAG of the calling task is used.

  • include_prior_dates (bool) – If False, only XComs from the current execution_date are returned. If True, XComs from previous dates are returned as well.

  • limit (int) – If required, limit the number of returned objects. XCom objects can be quite big and you might want to limit the number of rows.

  • session (sqlalchemy.orm.session.Session) – database session

classmethod delete(cls, xcoms, session=None)[source]

Delete Xcom

static serialize_value(value: Any)[source]

Serialize Xcom value to str or pickled object

static deserialize_value(result: ‘XCom’)[source]

Deserialize XCom value from str or pickle object

orm_deserialize_value(self)[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]
Resolves custom XCom class
airflow.models.xcom.XCom[source]

Was this entry helpful?