Skip to main content

prefect.variables

Classes

Variable

Variables are named, mutable JSON values that can be shared across tasks and flows. Args:
  • name: A string identifying the variable.
  • value: A string that is the value of the variable.
  • tags: An optional list of strings to associate with the variable.
Methods:

aget

aget

aget

Asynchronously get a variable’s value by name. If the variable does not exist, return the default value. Args:
  • - name: The name of the variable value to get.
  • - default: The default value to return if the variable does not exist.

aset

Asynchronously sets a new variable. If one exists with the same name, must pass overwrite=True Returns the newly set variable object. Args:
  • - name: The name of the variable to set.
  • - value: The value of the variable to set.
  • - tags: An optional list of strings to associate with the variable.
  • - overwrite: Whether to overwrite the variable if it already exists.

aunset

Asynchronously unset a variable by name. Args:
  • - name: The name of the variable to unset.
Returns True if the variable was deleted, False if the variable did not exist.

get

get

get

Get a variable’s value by name. If the variable does not exist, return the default value. Args:
  • - name: The name of the variable value to get.
  • - default: The default value to return if the variable does not exist.

set

Sets a new variable. If one exists with the same name, must pass overwrite=True Returns the newly set variable object. Args:
  • - name: The name of the variable to set.
  • - value: The value of the variable to set.
  • - tags: An optional list of strings to associate with the variable.
  • - overwrite: Whether to overwrite the variable if it already exists.

unset

Unset a variable by name. Args:
  • - name: The name of the variable to unset.
Returns True if the variable was deleted, False if the variable did not exist.