Module Contents



Class to hold the default value of a Param and rule set to do the validations.


Class to hold all params for dags or tasks.


DAG run parameter reference.


process_params(dag, task, dag_run, *, suppress_exception)

Merge, validate params, and convert them into a simple dict.



class airflow.models.param.Param(default=NOTSET, description=None, **kwargs)[source]

Class to hold the default value of a Param and rule set to do the validations.

Without the rule set it always validates and returns the default value.

  • default (Any) – The value this Param object holds

  • description (str | None) – Optional help text for the Param

  • schema – The validation schema of the Param, if not given then all kwargs except default & description will form the schema

property has_value: bool[source]
__version__: ClassVar[int] = 1[source]
CLASS_IDENTIFIER = '__class'[source]
resolve(value=NOTSET, suppress_exception=False)[source]

Runs the validations and returns the Param’s final value.

May raise ValueError on failed validations, or TypeError if no value is passed and no value already exists. We first check that value is json-serializable; if not, warn. In future release we will require the value to be json-serializable.

  • value (Any) – The value to be updated for the Param

  • suppress_exception (bool) – To raise an exception or not when the validations fails. If true and validations fails, the return value would be None.


Dump the Param as a dictionary.

static deserialize(data, version)[source]
class airflow.models.param.ParamsDict(dict_obj=None, suppress_exception=False)[source]

Bases: MutableMapping[str, Any]

Class to hold all params for dags or tasks.

All the keys are strictly string and values are converted into Param’s object if they are not already. This class is to replace param’s dictionary implicitly and ideally not needed to be used directly.

  • dict_obj (MutableMapping | None) – A dict or dict like object to init ParamsDict

  • suppress_exception (bool) – Flag to suppress value exceptions while initializing the ParamsDict

__version__: ClassVar[int] = 1[source]
__slots__ = ['__dict', 'suppress_exception'][source]

Return self==value.


Return repr(self).

__setitem__(key, value)[source]

Override for dictionary’s setitem method to ensure all values are of Param’s type only.

  • key (str) – A key which needs to be inserted or updated in the dict

  • value (Any) – A value which needs to be set against the key. It could be of any type but will be converted and stored as a Param object eventually.


Override for dictionary’s getitem method to call the resolve method after fetching the key.


key (str) – The key to fetch


Get the internal Param object for this key.


D.items() -> a set-like object providing a view on D’s items


D.values() -> an object providing a view on D’s values

update(*args, **kwargs)[source]

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v


Dumps the ParamsDict object as a dictionary, while suppressing exceptions.


Validates & returns all the Params object stored in the dictionary.

static deserialize(data, version)[source]
class airflow.models.param.DagParam(current_dag, name, default=NOTSET)[source]

Bases: airflow.utils.mixins.ResolveMixin

DAG run parameter reference.

This binds a simple Param object to a name within a DAG instance, so that it can be resolved during the runtime via the {{ context }} dictionary. The ideal use case of this class is to implicitly convert args passed to a method decorated by @dag.

It can be used to parameterize a DAG. You can overwrite its value by setting it on conf when you trigger your DagRun.

This can also be used in templates by accessing {{ context.params }}.


with DAG(…) as dag:

EmailOperator(subject=dag.param(‘subject’, ‘Hi from Airflow!’))

  • current_dag (airflow.models.dag.DAG) – Dag being used for parameter.

  • name (str) – key value which is used to set the parameter

  • default (Any) – Default value used if no parameter was set.


Pull DagParam value from DagRun context. This method is run during op.execute().

airflow.models.param.process_params(dag, task, dag_run, *, suppress_exception)[source]

Merge, validate params, and convert them into a simple dict.

Was this entry helpful?