airflow.models.variable
¶
Module Contents¶
Classes¶
A generic way to store and retrieve arbitrary content or settings as a simple key/value store. |
Attributes¶
- class airflow.models.variable.Variable(key=None, val=None, description=None)[source]¶
Bases:
airflow.models.base.Base
,airflow.utils.log.logging_mixin.LoggingMixin
A generic way to store and retrieve arbitrary content or settings as a simple key/value store.
- classmethod setdefault(key, default, description=None, deserialize_json=False)[source]¶
Return the current value for a key or store the default value and return it.
Works the same as the Python builtin dict object.
- Parameters
key – Dict key for this Variable
default – Default value to set and return if the variable isn’t already in the DB
description – Default value to set Description of the Variable
deserialize_json – Store this as a JSON encoded value in the DB and un-encode it when retrieving a value
- Returns
Mixed
- classmethod get(key, default_var=__NO_DEFAULT_SENTINEL, deserialize_json=False)[source]¶
Get a value for an Airflow Variable Key.
- static set(key, value, description=None, serialize_json=False, session=None)[source]¶
Set a value for an Airflow Variable with a given Key.
This operation overwrites an existing variable.
- static update(key, value, serialize_json=False, session=None)[source]¶
Update a given Airflow Variable with the Provided value.
- static delete(key, session=None)[source]¶
Delete an Airflow Variable for a given key.
- Parameters
key (str) – Variable Keys
- static check_for_write_conflict(key)[source]¶
Log a warning if a variable exists outside the metastore.
If we try to write a variable to the metastore while the same key exists in an environment variable or custom secrets backend, then subsequent reads will not read the set value.
- Parameters
key (str) – Variable Key