docs/v3/api-ref/python/prefect-filesystems.mdx
prefect.filesystemsReadableFileSystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L25" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
adelete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1893" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>adelete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Asynchronously deletes the block document with the specified name.
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.aload <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1057" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Custom.aload("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Block.aload("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = await Custom.aload("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
aload_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1244" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Asynchronously retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
annotation_refers_to_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1442" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>annotation_refers_to_block_class(annotation: Any) -> bool
aregister_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1455" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aregister_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Asynchronously makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
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.asave <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1842" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>asave(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Asynchronously saves the values of a block as a block document.
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.Returns:
block_initialization <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L381" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>block_initialization(self) -> None
delete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1914" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Deletes the block document with the specified name.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L477" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_capabilities(cls) -> FrozenSet[str]
Returns the block capabilities for this Block. Recursively collects all block capabilities of all parent classes into a single frozenset.
get_block_class_from_key <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L902" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_key(cls: type[Self], key: str) -> type[Self]
Retrieve the block class implementation given a key.
get_block_class_from_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L895" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_schema(cls: type[Self], schema: BlockSchema) -> type[Self]
Retrieve the block class implementation given a schema.
get_block_placeholder <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1934" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_placeholder(self) -> str
Returns the block placeholder for the current block which can be used for templating.
Returns:
prefect.blocks.{block_type_name}.{block_document_name}Raises:
BlockNotSavedError: Raised if the block has not been saved.If a block has not been saved, the return value will be None.
get_block_schema_version <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L507" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_schema_version(cls) -> str
get_block_type_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L469" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_name(cls) -> str
get_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L473" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_slug(cls) -> str
get_code_example <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L750" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_code_example(cls) -> Optional[str]
Returns the code example for the given block. Attempts to parse code example from the class docstring if an override is not provided.
get_description <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L727" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_description(cls) -> Optional[str]
Returns the description for the current block. Attempts to parse description from class docstring if an override is not defined.
is_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1438" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_block_class(block: Any) -> TypeGuard[type['Block']]
load <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1146" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Custom.load("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Block.load("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = Custom.load("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
load_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1311" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
This function will dispatch to 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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was 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.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
model_dump <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2063" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_dump(self) -> dict[str, Any]
model_json_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2005" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_json_schema(cls, by_alias: bool = True, ref_template: str = '#/definitions/{model}', schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema, mode: Literal['validation', 'serialization'] = 'validation') -> dict[str, Any]
TODO: stop overriding this method - use GenerateSchema in ConfigDict instead?
model_validate <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2038" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_validate(cls: type[Self], obj: dict[str, Any] | Any) -> Self
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L29" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
register_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1554" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>register_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1866" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>save(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Saves the values of a block as a block document.
This function will dispatch to 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.Returns:
ser_model <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L424" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>ser_model(self, handler: SerializerFunctionWrapHandler, info: SerializationInfo) -> Any
validate_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L365" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>validate_block_type_slug(cls, values: Any) -> Any
Validates that the 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.
WritableFileSystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L33" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
adelete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1893" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>adelete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Asynchronously deletes the block document with the specified name.
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.aload <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1057" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Custom.aload("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Block.aload("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = await Custom.aload("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
aload_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1244" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Asynchronously retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
annotation_refers_to_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1442" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>annotation_refers_to_block_class(annotation: Any) -> bool
aregister_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1455" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aregister_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Asynchronously makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
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.asave <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1842" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>asave(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Asynchronously saves the values of a block as a block document.
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.Returns:
block_initialization <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L381" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>block_initialization(self) -> None
delete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1914" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Deletes the block document with the specified name.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L477" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_capabilities(cls) -> FrozenSet[str]
Returns the block capabilities for this Block. Recursively collects all block capabilities of all parent classes into a single frozenset.
get_block_class_from_key <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L902" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_key(cls: type[Self], key: str) -> type[Self]
Retrieve the block class implementation given a key.
get_block_class_from_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L895" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_schema(cls: type[Self], schema: BlockSchema) -> type[Self]
Retrieve the block class implementation given a schema.
get_block_placeholder <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1934" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_placeholder(self) -> str
Returns the block placeholder for the current block which can be used for templating.
Returns:
prefect.blocks.{block_type_name}.{block_document_name}Raises:
BlockNotSavedError: Raised if the block has not been saved.If a block has not been saved, the return value will be None.
get_block_schema_version <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L507" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_schema_version(cls) -> str
get_block_type_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L469" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_name(cls) -> str
get_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L473" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_slug(cls) -> str
get_code_example <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L750" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_code_example(cls) -> Optional[str]
Returns the code example for the given block. Attempts to parse code example from the class docstring if an override is not provided.
get_description <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L727" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_description(cls) -> Optional[str]
Returns the description for the current block. Attempts to parse description from class docstring if an override is not defined.
is_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1438" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_block_class(block: Any) -> TypeGuard[type['Block']]
load <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1146" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Custom.load("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Block.load("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = Custom.load("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
load_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1311" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
This function will dispatch to 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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was 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.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
model_dump <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2063" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_dump(self) -> dict[str, Any]
model_json_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2005" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_json_schema(cls, by_alias: bool = True, ref_template: str = '#/definitions/{model}', schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema, mode: Literal['validation', 'serialization'] = 'validation') -> dict[str, Any]
TODO: stop overriding this method - use GenerateSchema in ConfigDict instead?
model_validate <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2038" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_validate(cls: type[Self], obj: dict[str, Any] | Any) -> Self
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L37" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
register_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1554" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>register_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1866" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>save(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Saves the values of a block as a block document.
This function will dispatch to 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.Returns:
ser_model <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L424" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>ser_model(self, handler: SerializerFunctionWrapHandler, info: SerializationInfo) -> Any
validate_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L365" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>validate_block_type_slug(cls, values: Any) -> Any
Validates that the 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_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> None
ReadableDeploymentStorage <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L45" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
adelete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1893" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>adelete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Asynchronously deletes the block document with the specified name.
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.aload <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1057" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Custom.aload("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Block.aload("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = await Custom.aload("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
aload_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1244" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Asynchronously retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
annotation_refers_to_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1442" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>annotation_refers_to_block_class(annotation: Any) -> bool
aregister_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1455" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aregister_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Asynchronously makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
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.asave <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1842" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>asave(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Asynchronously saves the values of a block as a block document.
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.Returns:
block_initialization <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L381" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>block_initialization(self) -> None
delete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1914" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Deletes the block document with the specified name.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L477" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_capabilities(cls) -> FrozenSet[str]
Returns the block capabilities for this Block. Recursively collects all block capabilities of all parent classes into a single frozenset.
get_block_class_from_key <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L902" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_key(cls: type[Self], key: str) -> type[Self]
Retrieve the block class implementation given a key.
get_block_class_from_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L895" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_schema(cls: type[Self], schema: BlockSchema) -> type[Self]
Retrieve the block class implementation given a schema.
get_block_placeholder <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1934" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_placeholder(self) -> str
Returns the block placeholder for the current block which can be used for templating.
Returns:
prefect.blocks.{block_type_name}.{block_document_name}Raises:
BlockNotSavedError: Raised if the block has not been saved.If a block has not been saved, the return value will be None.
get_block_schema_version <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L507" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_schema_version(cls) -> str
get_block_type_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L469" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_name(cls) -> str
get_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L473" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_slug(cls) -> str
get_code_example <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L750" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_code_example(cls) -> Optional[str]
Returns the code example for the given block. Attempts to parse code example from the class docstring if an override is not provided.
get_description <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L727" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_description(cls) -> Optional[str]
Returns the description for the current block. Attempts to parse description from class docstring if an override is not defined.
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L49" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
is_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1438" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_block_class(block: Any) -> TypeGuard[type['Block']]
load <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1146" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Custom.load("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Block.load("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = Custom.load("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
load_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1311" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
This function will dispatch to 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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was 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.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
model_dump <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2063" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_dump(self) -> dict[str, Any]
model_json_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2005" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_json_schema(cls, by_alias: bool = True, ref_template: str = '#/definitions/{model}', schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema, mode: Literal['validation', 'serialization'] = 'validation') -> dict[str, Any]
TODO: stop overriding this method - use GenerateSchema in ConfigDict instead?
model_validate <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2038" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_validate(cls: type[Self], obj: dict[str, Any] | Any) -> Self
register_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1554" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>register_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1866" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>save(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Saves the values of a block as a block document.
This function will dispatch to 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.Returns:
ser_model <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L424" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>ser_model(self, handler: SerializerFunctionWrapHandler, info: SerializationInfo) -> Any
validate_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L365" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>validate_block_type_slug(cls, values: Any) -> Any
Validates that the 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.
WritableDeploymentStorage <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L55" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Methods:
adelete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1893" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>adelete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Asynchronously deletes the block document with the specified name.
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.aload <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1057" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Custom.aload("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = await Block.aload("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = await Custom.aload("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
aload_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1244" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aload_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Asynchronously retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
annotation_refers_to_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1442" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>annotation_refers_to_block_class(annotation: Any) -> bool
aregister_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1455" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aregister_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Asynchronously makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
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.asave <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1842" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>asave(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Asynchronously saves the values of a block as a block document.
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.Returns:
block_initialization <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L381" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>block_initialization(self) -> None
delete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1914" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete(cls, name: str, client: Optional['PrefectClient'] = None) -> None
Deletes the block document with the specified name.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L477" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_capabilities(cls) -> FrozenSet[str]
Returns the block capabilities for this Block. Recursively collects all block capabilities of all parent classes into a single frozenset.
get_block_class_from_key <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L902" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_key(cls: type[Self], key: str) -> type[Self]
Retrieve the block class implementation given a key.
get_block_class_from_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L895" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_class_from_schema(cls: type[Self], schema: BlockSchema) -> type[Self]
Retrieve the block class implementation given a schema.
get_block_placeholder <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1934" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_placeholder(self) -> str
Returns the block placeholder for the current block which can be used for templating.
Returns:
prefect.blocks.{block_type_name}.{block_document_name}Raises:
BlockNotSavedError: Raised if the block has not been saved.If a block has not been saved, the return value will be None.
get_block_schema_version <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L507" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_schema_version(cls) -> str
get_block_type_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L469" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_name(cls) -> str
get_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L473" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_block_type_slug(cls) -> str
get_code_example <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L750" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_code_example(cls) -> Optional[str]
Returns the code example for the given block. Attempts to parse code example from the class docstring if an override is not provided.
get_description <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L727" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_description(cls) -> Optional[str]
Returns the description for the current block. Attempts to parse description from class docstring if an override is not defined.
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
is_block_class <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1438" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_block_class(block: Any) -> TypeGuard[type['Block']]
load <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1146" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load(cls, name: str, validate: bool = True, client: Optional['PrefectClient'] = None) -> 'Self'
Retrieves data from the block document with the given name for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was saved.client: The client to use to load the block document. If not provided, the
default client will be injected.Raises:
ValueError: If the requested block document is not found.Returns:
Examples:
Load from a Block subclass with a block document name:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Custom.load("my-custom-message")
Load from Block with a block document slug:
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
loaded_block = Block.load("custom/my-custom-message")
Migrate a block document to a new schema:
# original class
class Custom(Block):
message: str
Custom(message="Hello!").save("my-custom-message")
# Updated class with new required field
class Custom(Block):
message: str
number_of_ducks: int
loaded_block = Custom.load("my-custom-message", validate=False)
# Prints UserWarning about schema mismatch
loaded_block.number_of_ducks = 42
loaded_block.save("my-custom-message", overwrite=True)
load_from_ref <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1311" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>load_from_ref(cls, ref: Union[str, UUID, dict[str, Any]], validate: bool = True, client: 'PrefectClient | None' = None) -> Self
Retrieves data from the block document by given reference for the block type that corresponds with the current class and returns an instantiated version of the current class with the data stored in the block document.
This function will dispatch to 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>}If a block document for a given block type is saved with a different schema
than the current class calling 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 by name was 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.Raises:
ValueError: If invalid reference format is provided.ValueError: If the requested block document is not found.Returns:
model_dump <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2063" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_dump(self) -> dict[str, Any]
model_json_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2005" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_json_schema(cls, by_alias: bool = True, ref_template: str = '#/definitions/{model}', schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema, mode: Literal['validation', 'serialization'] = 'validation') -> dict[str, Any]
TODO: stop overriding this method - use GenerateSchema in ConfigDict instead?
model_validate <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L2038" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>model_validate(cls: type[Self], obj: dict[str, Any] | Any) -> Self
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
register_type_and_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1554" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>register_type_and_schema(cls, client: Optional['PrefectClient'] = None) -> None
Makes block available for configuration with current Prefect API. Recursively registers all nested blocks. Registration is idempotent.
This function will dispatch to 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 <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L1866" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>save(self, name: Optional[str] = None, overwrite: bool = False, client: Optional['PrefectClient'] = None) -> UUID
Saves the values of a block as a block document.
This function will dispatch to 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.Returns:
ser_model <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L424" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>ser_model(self, handler: SerializerFunctionWrapHandler, info: SerializationInfo) -> Any
validate_block_type_slug <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/core.py#L365" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>validate_block_type_slug(cls, values: Any) -> Any
Validates that the 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.
LocalFileSystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L74" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Store data as a file on a local file system.
Methods:
aget_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L128" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aget_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
Copies a directory from one place to another on the local filesystem.
Defaults to copying the entire contents of the block's basepath to the current working directory.
aput_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L225" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aput_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
Copies a directory from one place to another on the local filesystem.
Defaults to copying the entire contents of the current working directory to the block's basepath.
An ignore_file path may be provided that can include gitignore style expressions for filepaths to ignore.
aread_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L303" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aread_path(self, path: str) -> bytes
awrite_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L336" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>awrite_path(self, path: str, content: bytes) -> str
cast_pathlib <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L98" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>cast_pathlib(cls, value: str | Path | None) -> str | None
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L165" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
Copies a directory from one place to another on the local filesystem.
Defaults to copying the entire contents of the block's basepath to the current working directory.
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L260" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
Copies a directory from one place to another on the local filesystem.
Defaults to copying the entire contents of the current working directory to the block's basepath.
An ignore_file path may be provided that can include gitignore style expressions for filepaths to ignore.
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L320" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L37" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L352" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> str
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> None
RemoteFileSystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L368" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Store data as a file on a remote file system.
Supports any remote file system supported by fsspec. The file system is specified
using a protocol. For example, "s3://my-bucket/my-folder/" will use S3.
Methods:
aget_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L429" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aget_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
Downloads a directory from a given remote path to a local directory.
Defaults to downloading the entire contents of the block's basepath to the current working directory.
aput_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L476" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aput_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None, overwrite: bool = True) -> int
Uploads a directory from a given local path to a remote directory.
Defaults to uploading the entire contents of the current working directory to the block's basepath.
aread_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L585" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aread_path(self, path: str) -> bytes
awrite_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L602" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>awrite_path(self, path: str, content: bytes) -> str
check_basepath <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L404" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>check_basepath(cls, value: str) -> str
filesystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L632" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>filesystem(self) -> fsspec.AbstractFileSystem
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L454" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
Downloads a directory from a given remote path to a local directory.
Defaults to downloading the entire contents of the block's basepath to the current working directory.
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L532" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None, overwrite: bool = True) -> int
Uploads a directory from a given local path to a remote directory.
Defaults to uploading the entire contents of the current working directory to the block's basepath.
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L594" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L37" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L617" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> str
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> None
SMB <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L650" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Store data as a file on a SMB share.
Methods:
aget_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L712" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aget_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> bytes
Downloads a directory from a given remote path to a local directory. Defaults to downloading the entire contents of the block's basepath to the current working directory.
aput_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L733" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aput_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> int
Uploads a directory from a given local path to a remote directory. Defaults to uploading the entire contents of the current working directory to the block's basepath.
aread_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L768" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aread_path(self, path: str) -> bytes
awrite_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L775" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>awrite_path(self, path: str, content: bytes) -> str
basepath <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L692" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>basepath(self) -> str
filesystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L696" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>filesystem(self) -> RemoteFileSystem
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L724" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> bytes
Downloads a directory from a given remote path to a local directory. Defaults to downloading the entire contents of the block's basepath to the current working directory.
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L751" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> int
Uploads a directory from a given local path to a remote directory. Defaults to uploading the entire contents of the current working directory to the block's basepath.
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L772" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L37" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L779" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> str
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> None
NullFileSystem <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L783" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>A file system that does not store any data.
Methods:
get_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L794" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None
put_directory <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L799" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>put_directory(self, local_path: Optional[str] = None, to_path: Optional[str] = None, ignore_file: Optional[str] = None) -> None
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L788" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> None
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L791" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> None