airflow.models.renderedtifields

Save Rendered Template Fields

Module Contents

Classes

RenderedTaskInstanceFields

Save Rendered Template Fields

class airflow.models.renderedtifields.RenderedTaskInstanceFields(ti, render_templates=True)[source]

Bases: airflow.models.base.Base

Save Rendered Template Fields

__tablename__ = rendered_task_instance_fields[source]
dag_id[source]
task_id[source]
run_id[source]
map_index[source]
rendered_fields[source]
k8s_pod_yaml[source]
__table_args__[source]
task_instance[source]
dag_run[source]
execution_date[source]
__repr__()[source]
classmethod get_templated_fields(ti, session=NEW_SESSION)[source]

Get templated field for a TaskInstance from the RenderedTaskInstanceFields table.

Parameters
Returns

Rendered Templated TI field

Return type

Optional[dict]

classmethod get_k8s_pod_yaml(ti, session=NEW_SESSION)[source]

Get rendered Kubernetes Pod Yaml for a TaskInstance from the RenderedTaskInstanceFields table.

Parameters
Returns

Kubernetes Pod Yaml

Return type

Optional[dict]

write(session=None)[source]

Write instance to database

Parameters

session (sqlalchemy.orm.Session) – SqlAlchemy Session

classmethod delete_old_records(task_id, dag_id, num_to_keep=conf.getint('core', 'max_num_rendered_ti_fields_per_task', fallback=0), session=None)[source]

Keep only Last X (num_to_keep) number of records for a task by deleting others.

In the case of data for a mapped task either all of the rows or none of the rows will be deleted, so we don’t end up with partial data for a set of mapped Task Instances left in the database.

Parameters
  • task_id (str) – Task ID

  • dag_id (str) – Dag ID

  • num_to_keep – Number of Records to keep

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

Was this entry helpful?