prefect.blocks.abstract
Classes
CredentialsBlock
Stores credentials for an external system and exposes a client for interacting
with that system. Can also hold config that is tightly coupled to credentials
(domain, endpoint, account ID, etc.) Will often be composed with other blocks.
Parent block should rely on the client provided by a credentials block for
interacting with the corresponding external system.
Methods:
adelete
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected.
aload
aload, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
aload_from_ref
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
aload_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
annotation_refers_to_block_class
aregister_type_and_schema
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided.
asave
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected.
- The ID of the saved block document.
block_initialization
delete
adelete when called from an async context.
Args:
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
get_block_capabilities
get_block_class_from_key
get_block_class_from_schema
get_block_placeholder
- The block placeholder for the current block in the format
prefect.blocks.{block_type_name}.{block_document_name}
BlockNotSavedError: Raised if the block has not been saved.
None.
get_block_schema_version
get_block_type_name
get_block_type_slug
get_client
client_type keyword argument to get the desired client
within the service.
get_code_example
get_description
is_block_class
load
load, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
load_from_ref
aload_from_ref when called from an async context.
Provided reference can be a block document ID, or a reference data in dictionary format.
Supported dictionary reference formats are:
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
load_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
logger
- The run logger or a default logger with the class’s name.
model_dump
model_json_schema
model_validate
register_type_and_schema
aregister_type_and_schema when called from an async context.
Args:
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided. This is ignored when called from a synchronous context.
save
asave when called from an async context.
Args:
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
- The ID of the saved block document.
ser_model
validate_block_type_slug
block_type_slug in the input values matches the expected
block type slug for the class. This helps pydantic to correctly discriminate
between different Block subclasses when validating Union types of Blocks.
NotificationError
Raised if a notification block fails to send a notification.
NotificationBlock
Block that represents a resource in an external system that is able to send notifications.
Methods:
adelete
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected.
aload
aload, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
aload_from_ref
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
aload_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
annotation_refers_to_block_class
aregister_type_and_schema
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided.
asave
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected.
- The ID of the saved block document.
block_initialization
delete
adelete when called from an async context.
Args:
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
get_block_capabilities
get_block_class_from_key
get_block_class_from_schema
get_block_placeholder
- The block placeholder for the current block in the format
prefect.blocks.{block_type_name}.{block_document_name}
BlockNotSavedError: Raised if the block has not been saved.
None.
get_block_schema_version
get_block_type_name
get_block_type_slug
get_code_example
get_description
is_block_class
load
load, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
load_from_ref
aload_from_ref when called from an async context.
Provided reference can be a block document ID, or a reference data in dictionary format.
Supported dictionary reference formats are:
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
load_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
logger
- The run logger or a default logger with the class’s name.
model_dump
model_json_schema
model_validate
notify
body: The body of the notification.subject: The subject of the notification.
raise_on_failure
register_type_and_schema
aregister_type_and_schema when called from an async context.
Args:
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided. This is ignored when called from a synchronous context.
save
asave when called from an async context.
Args:
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
- The ID of the saved block document.
ser_model
validate_block_type_slug
block_type_slug in the input values matches the expected
block type slug for the class. This helps pydantic to correctly discriminate
between different Block subclasses when validating Union types of Blocks.
JobRun
Represents a job run in an external system. Allows waiting
for the job run’s completion and fetching its results.
Methods:
fetch_result
logger
- The run logger or a default logger with the class’s name.
wait_for_completion
JobBlock
Block that represents an entity in an external service
that can trigger a long running execution.
Methods:
adelete
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected.
aload
aload, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
aload_from_ref
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
aload_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
annotation_refers_to_block_class
aregister_type_and_schema
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided.
asave
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected.
- The ID of the saved block document.
block_initialization
delete
adelete when called from an async context.
Args:
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
get_block_capabilities
get_block_class_from_key
get_block_class_from_schema
get_block_placeholder
- The block placeholder for the current block in the format
prefect.blocks.{block_type_name}.{block_document_name}
BlockNotSavedError: Raised if the block has not been saved.
None.
get_block_schema_version
get_block_type_name
get_block_type_slug
get_code_example
get_description
is_block_class
load
load, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
load_from_ref
aload_from_ref when called from an async context.
Provided reference can be a block document ID, or a reference data in dictionary format.
Supported dictionary reference formats are:
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
load_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
logger
- The run logger or a default logger with the class’s name.
model_dump
model_json_schema
model_validate
register_type_and_schema
aregister_type_and_schema when called from an async context.
Args:
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided. This is ignored when called from a synchronous context.
save
asave when called from an async context.
Args:
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
- The ID of the saved block document.
ser_model
trigger
validate_block_type_slug
block_type_slug in the input values matches the expected
block type slug for the class. This helps pydantic to correctly discriminate
between different Block subclasses when validating Union types of Blocks.
DatabaseBlock
An abstract block type that represents a database and
provides an interface for interacting with it.
Blocks that implement this interface have the option to accept
credentials directly via attributes or via a nested CredentialsBlock.
Use of a nested credentials block is recommended unless credentials
are tightly coupled to database connection configuration.
Implementing either sync or async context management on DatabaseBlock
implementations is recommended.
Methods:
adelete
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected.
aload
aload, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
aload_from_ref
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
aload_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
annotation_refers_to_block_class
aregister_type_and_schema
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided.
asave
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected.
- The ID of the saved block document.
block_initialization
delete
adelete when called from an async context.
Args:
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
execute
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.**execution_kwargs: Additional keyword arguments to pass to execute.
execute_many
operation: The SQL query or other operation to be executed.seq_of_parameters: The sequence of parameters for the operation.**execution_kwargs: Additional keyword arguments to pass to execute.
fetch_all
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.**execution_kwargs: Additional keyword arguments to pass to execute.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_many
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.size: The number of results to return.**execution_kwargs: Additional keyword arguments to pass to execute.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
fetch_one
operation: The SQL query or other operation to be executed.parameters: The parameters for the operation.**execution_kwargs: Additional keyword arguments to pass to execute.
- A list of tuples containing the data returned by the database, where each row is a tuple and each column is a value in the tuple.
get_block_capabilities
get_block_class_from_key
get_block_class_from_schema
get_block_placeholder
- The block placeholder for the current block in the format
prefect.blocks.{block_type_name}.{block_document_name}
BlockNotSavedError: Raised if the block has not been saved.
None.
get_block_schema_version
get_block_type_name
get_block_type_slug
get_code_example
get_description
is_block_class
load
load, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
load_from_ref
aload_from_ref when called from an async context.
Provided reference can be a block document ID, or a reference data in dictionary format.
Supported dictionary reference formats are:
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
load_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
logger
- The run logger or a default logger with the class’s name.
model_dump
model_json_schema
model_validate
register_type_and_schema
aregister_type_and_schema when called from an async context.
Args:
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided. This is ignored when called from a synchronous context.
save
asave when called from an async context.
Args:
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
- The ID of the saved block document.
ser_model
validate_block_type_slug
block_type_slug in the input values matches the expected
block type slug for the class. This helps pydantic to correctly discriminate
between different Block subclasses when validating Union types of Blocks.
ObjectStorageBlock
Block that represents a resource in an external service that can store
objects.
Methods:
adelete
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected.
aload
aload, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
aload_from_ref
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
aload_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
annotation_refers_to_block_class
aregister_type_and_schema
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided.
asave
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected.
- The ID of the saved block document.
block_initialization
delete
adelete when called from an async context.
Args:
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
download_folder_to_path
from_folder: The path to the folder to download from.to_folder: The path to download the folder to.**download_kwargs: Additional keyword arguments to pass to download.
- The path that the folder was downloaded to.
download_object_to_file_object
from_path: The path to download from.to_file_object: The file-like object to download to.**download_kwargs: Additional keyword arguments to pass to download.
- The file-like object that the object was downloaded to.
download_object_to_path
from_path: The path to download from.to_path: The path to download to.**download_kwargs: Additional keyword arguments to pass to download.
- The path that the object was downloaded to.
get_block_capabilities
get_block_class_from_key
get_block_class_from_schema
get_block_placeholder
- The block placeholder for the current block in the format
prefect.blocks.{block_type_name}.{block_document_name}
BlockNotSavedError: Raised if the block has not been saved.
None.
get_block_schema_version
get_block_type_name
get_block_type_slug
get_code_example
get_description
is_block_class
load
load, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
load_from_ref
aload_from_ref when called from an async context.
Provided reference can be a block document ID, or a reference data in dictionary format.
Supported dictionary reference formats are:
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
load_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
logger
- The run logger or a default logger with the class’s name.
model_dump
model_json_schema
model_validate
register_type_and_schema
aregister_type_and_schema when called from an async context.
Args:
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided. This is ignored when called from a synchronous context.
save
asave when called from an async context.
Args:
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
- The ID of the saved block document.
ser_model
upload_from_file_object
from_file_object: The file-like object to upload from.to_path: The path to upload the object to.**upload_kwargs: Additional keyword arguments to pass to upload.
- The path that the object was uploaded to.
upload_from_folder
from_folder: The path to the folder to upload from.to_folder: The path to upload the folder to.**upload_kwargs: Additional keyword arguments to pass to upload.
- The path that the folder was uploaded to.
upload_from_path
from_path: The path to the file to upload from.to_path: The path to upload the file to.**upload_kwargs: Additional keyword arguments to pass to upload.
- The path that the object was uploaded to.
validate_block_type_slug
block_type_slug in the input values matches the expected
block type slug for the class. This helps pydantic to correctly discriminate
between different Block subclasses when validating Union types of Blocks.
SecretBlock
Block that represents a resource that can store and retrieve secrets.
Methods:
adelete
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected.
aload
aload, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
aload_from_ref
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
aload_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, aload_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
annotation_refers_to_block_class
aregister_type_and_schema
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided.
asave
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected.
- The ID of the saved block document.
block_initialization
delete
adelete when called from an async context.
Args:
name: The name of the block document to delete.client: The client to use to delete the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
get_block_capabilities
get_block_class_from_key
get_block_class_from_schema
get_block_placeholder
- The block placeholder for the current block in the format
prefect.blocks.{block_type_name}.{block_document_name}
BlockNotSavedError: Raised if the block has not been saved.
None.
get_block_schema_version
get_block_type_name
get_block_type_slug
get_code_example
get_description
is_block_class
load
load, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
name: The name or slug of the block document. A block document slug is a string with the format<block_type_slug>/<block_document_name>validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected.
ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
load_from_ref
aload_from_ref when called from an async context.
Provided reference can be a block document ID, or a reference data in dictionary format.
Supported dictionary reference formats are:
{"block_document_id": <block_document_id>}{"block_document_slug": <block_document_slug>}
load_from_ref, a warning will be raised.
If the current class schema is a subset of the block document schema, the block
can be loaded as normal using the default validate = True.
If the current class schema is a superset of the block document schema, load_from_ref
must be called with validate set to False to prevent a validation error. In
this case, the block attributes will default to None and must be set manually
and saved to a new block document before the block can be used as expected.
Args:
ref: The reference to the block document. This can be a block document ID, or one of supported dictionary reference formats.validate: If False, the block document will be loaded without Pydantic validating the block schema. This is useful if the block schema has changed client-side since the block document referred to bynamewas saved.client: The client to use to load the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.
- An instance of the current class hydrated with the data stored in the
- block document with the specified name.
logger
- The run logger or a default logger with the class’s name.
model_dump
model_json_schema
model_validate
read_secret
- The secret data.
register_type_and_schema
aregister_type_and_schema when called from an async context.
Args:
client: Optional client to use for registering type and schema with the Prefect API. A new client will be created and used if one is not provided. This is ignored when called from a synchronous context.
save
asave when called from an async context.
Args:
name: User specified name to give saved block document which can later be used to load the block document.overwrite: Boolean value specifying if values should be overwritten if a block document with the specified name already exists.client: The client to use to save the block document. If not provided, the default client will be injected. This is ignored when called from a synchronous context.
- The ID of the saved block document.
ser_model
validate_block_type_slug
block_type_slug in the input values matches the expected
block type slug for the class. This helps pydantic to correctly discriminate
between different Block subclasses when validating Union types of Blocks.
write_secret
secret_data: The secret data to write.
- The key of the secret that can be used for retrieval.