airflow.models.dagcode

Module Contents

Classes

DagCode

A table for DAGs code.

Attributes

log

airflow.models.dagcode.log[source]
class airflow.models.dagcode.DagCode(full_filepath, source_code=None)[source]

Bases: airflow.models.base.Base

A table for DAGs code.

dag_code table contains code of DAG files synchronized by scheduler.

For details on dag serialization see SerializedDagModel

__tablename__ = dag_code[source]
fileloc_hash[source]
fileloc[source]
last_updated[source]
source_code[source]
sync_to_db(self, session=None)[source]

Writes code into database.

Parameters

session -- ORM Session

classmethod bulk_sync_to_db(cls, filelocs, session=None)[source]

Writes code in bulk into database.

Parameters
  • filelocs (Iterable[str]) -- file paths of DAGs to sync

  • session -- ORM Session

classmethod remove_deleted_code(cls, alive_dag_filelocs, session=None)[source]

Deletes code not included in alive_dag_filelocs.

Parameters
  • alive_dag_filelocs (List[str]) -- file paths of alive DAGs

  • session -- ORM Session

classmethod has_dag(cls, fileloc, session=None)[source]

Checks a file exist in dag_code table.

Parameters
  • fileloc (str) -- the file to check

  • session -- ORM Session

classmethod get_code_by_fileloc(cls, fileloc)[source]

Returns source code for a given fileloc.

Parameters

fileloc (str) -- file path of a DAG

Returns

source code as string

Return type

str

classmethod code(cls, fileloc)[source]

Returns source code for this DagCode object.

Returns

source code as string

Return type

str

static dag_fileloc_hash(full_filepath)[source]

Hashing file location for indexing.

Parameters

full_filepath (str) -- full filepath of DAG file

Returns

hashed full_filepath

Return type

int

Was this entry helpful?