templating
prefect.utilities.templating
Functions
determine_placeholder_type
Determines the type of a placeholder based on its name.
Args:
name
: The name of the placeholder
Returns:
- The type of the placeholder
find_placeholders
Finds all placeholders in a template.
Args:
template
: template to discover placeholders in
Returns:
- A set of all placeholders in the template
apply_values
Replaces placeholders in a template with values from a supplied dictionary.
Will recursively replace placeholders in dictionaries and lists.
If a value has no placeholders, it will be returned unchanged.
If a template contains only a single placeholder, the placeholder will be fully replaced with the value.
If a template contains text before or after a placeholder or there are multiple placeholders, the placeholders will be replaced with the corresponding variable values.
If a template contains a placeholder that is not in values
, NotSet will
be returned to signify that no placeholder replacement occurred. If
template
is a dictionary that contains a key with a value of NotSet,
the key will be removed in the return value unless remove_notset
is set to False.
Args:
template
: template to discover and replace values invalues
: The values to apply to placeholders in the templateremove_notset
: If True, remove keys with an unset valuewarn_on_notset
: If True, warn when a placeholder is not found invalues
Returns:
- The template with the values applied