| :py:mod:`airflow.models.pool` |
| ============================= |
| |
| .. py:module:: airflow.models.pool |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.models.pool.PoolStats |
| airflow.models.pool.Pool |
| |
| |
| |
| |
| .. py:class:: PoolStats |
| |
| Bases: :py:obj:`airflow.typing_compat.TypedDict` |
| |
| Dictionary containing Pool Stats |
| |
| .. py:attribute:: total |
| :annotation: :int |
| |
| |
| |
| .. py:attribute:: running |
| :annotation: :int |
| |
| |
| |
| .. py:attribute:: queued |
| :annotation: :int |
| |
| |
| |
| .. py:attribute:: open |
| :annotation: :int |
| |
| |
| |
| |
| .. py:class:: Pool |
| |
| Bases: :py:obj:`airflow.models.base.Base` |
| |
| the class to get Pool info. |
| |
| .. py:attribute:: __tablename__ |
| :annotation: = slot_pool |
| |
| |
| |
| .. py:attribute:: id |
| |
| |
| |
| |
| .. py:attribute:: pool |
| |
| |
| |
| |
| .. py:attribute:: slots |
| |
| |
| |
| |
| .. py:attribute:: description |
| |
| |
| |
| |
| .. py:attribute:: DEFAULT_POOL_NAME |
| :annotation: = default_pool |
| |
| |
| |
| .. py:method:: __repr__(self) |
| |
| Return repr(self). |
| |
| |
| .. py:method:: get_pools(session: sqlalchemy.orm.session.Session = NEW_SESSION) |
| :staticmethod: |
| |
| Get all pools. |
| |
| |
| .. py:method:: get_pool(pool_name: str, session: sqlalchemy.orm.session.Session = NEW_SESSION) |
| :staticmethod: |
| |
| Get the Pool with specific pool name from the Pools. |
| |
| :param pool_name: The pool name of the Pool to get. |
| :param session: SQLAlchemy ORM Session |
| :return: the pool object |
| |
| |
| .. py:method:: get_default_pool(session: sqlalchemy.orm.session.Session = NEW_SESSION) |
| :staticmethod: |
| |
| Get the Pool of the default_pool from the Pools. |
| |
| :param session: SQLAlchemy ORM Session |
| :return: the pool object |
| |
| |
| .. py:method:: is_default_pool(id: int, session: sqlalchemy.orm.session.Session = NEW_SESSION) -> bool |
| :staticmethod: |
| |
| Check id if is the default_pool. |
| |
| :param id: pool id |
| :param session: SQLAlchemy ORM Session |
| :return: True if id is default_pool, otherwise False |
| |
| |
| .. py:method:: create_or_update_pool(name: str, slots: int, description: str, session: sqlalchemy.orm.session.Session = NEW_SESSION) |
| :staticmethod: |
| |
| Create a pool with given parameters or update it if it already exists. |
| |
| |
| .. py:method:: delete_pool(name: str, session: sqlalchemy.orm.session.Session = NEW_SESSION) |
| :staticmethod: |
| |
| Delete pool by a given name. |
| |
| |
| .. py:method:: slots_stats(lock_rows: bool = False, session: sqlalchemy.orm.session.Session = NEW_SESSION) -> Dict[str, PoolStats] |
| :staticmethod: |
| |
| Get Pool stats (Number of Running, Queued, Open & Total tasks) |
| |
| If ``lock_rows`` is True, and the database engine in use supports the ``NOWAIT`` syntax, then a |
| non-blocking lock will be attempted -- if the lock is not available then SQLAlchemy will throw an |
| OperationalError. |
| |
| :param lock_rows: Should we attempt to obtain a row-level lock on all the Pool rows returns |
| :param session: SQLAlchemy ORM Session |
| |
| |
| .. py:method:: to_json(self) |
| |
| Get the Pool in a json structure |
| |
| :return: the pool object in json format |
| |
| |
| .. py:method:: occupied_slots(self, session: sqlalchemy.orm.session.Session) |
| |
| Get the number of slots used by running/queued tasks at the moment. |
| |
| :param session: SQLAlchemy ORM Session |
| :return: the used number of slots |
| |
| |
| .. py:method:: running_slots(self, session: sqlalchemy.orm.session.Session) |
| |
| Get the number of slots used by running tasks at the moment. |
| |
| :param session: SQLAlchemy ORM Session |
| :return: the used number of slots |
| |
| |
| .. py:method:: queued_slots(self, session: sqlalchemy.orm.session.Session) |
| |
| Get the number of slots used by queued tasks at the moment. |
| |
| :param session: SQLAlchemy ORM Session |
| :return: the used number of slots |
| |
| |
| .. py:method:: open_slots(self, session: sqlalchemy.orm.session.Session = NEW_SESSION) -> float |
| |
| Get the number of slots open at the moment. |
| |
| :param session: SQLAlchemy ORM Session |
| :return: the number of slots |
| |
| |
| |