airflow.models.xcom
¶
Module Contents¶
-
class
airflow.models.xcom.
BaseXCom
[source]¶ Bases:
airflow.models.base.Base
,airflow.utils.log.logging_mixin.LoggingMixin
Base class for XCom objects.
-
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.
-
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
-
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.
-