Documentation Index
Fetch the complete documentation index at: https://docs.prefect.io/llms.txt
Use this file to discover all available pages before exploring further.
prefect.utilities.templating
Functions
determine_placeholder_type
name: The name of the placeholder
- The type of the placeholder
find_placeholders
template: template to discover placeholders in
- A set of all placeholders in the template
apply_values
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 invaluesskip_prefixes: If provided, placeholders whose names start with any of these prefixes will be left untouched in the template.
- The template with the values applied
resolve_block_document_references
<block_document_id> is the ID of the block document to resolve.
Once the block document is retrieved from the API, the data of the block document
is used to replace the reference.
Accessing Values:
To access different values in a block document, use dot notation combined with the block document’s prefix, slug, and block name. For a block document with the structure:-
Accessing a nested dictionary:
Format:
prefect.blocks.<block_type_slug>.<block_document_name>.value.keyExample: Returns{"nested-key": "nested-value"} -
Accessing a specific nested value:
Format:
prefect.blocks.<block_type_slug>.<block_document_name>.value.key.nested-keyExample: Returns"nested-value" -
Accessing a list element’s key-value:
Format:
prefect.blocks.<block_type_slug>.<block_document_name>.value.list[0].list-keyExample: Returns"list-value"
Default Resolution for System Blocks:
For system blocks, which only contain avalue attribute, this attribute is resolved by default.
Inline Substitution:
Block placeholders can be used either as an entire string value (e.g.,"{{ prefect.blocks.secret.my-token }}") or embedded within other text
(e.g., "{{ prefect.blocks.secret.my-registry }}/my-image").
When embedded in other text, the resolved block value is coerced to a string and
substituted in place. If a placeholder resolves to a non-scalar value (e.g., a
dict or list), a ValueError is raised because there is no unambiguous
inline string representation.
Args:
template: The template to resolve block documents invalue_transformer: A function that takes the block placeholder and the block value and returns replacement text for the template
- The template with block documents resolved
resolve_variables
template: The template to resolve variables in
- The template with variables resolved