pyiron_workflow.storage module
A bit of abstraction connecting generic storage routines to nodes.
- exception pyiron_workflow.storage.FileTypeError[source]
Bases:
TypeErrorRaised when you’re looking for a save file, and you find something, but the file appears to be the wrong type.
- class pyiron_workflow.storage.H5BagStorage[source]
Bases:
StorageInterfaceStorage using
bagofholding.H5Bag.
- class pyiron_workflow.storage.PickleStorage(cloudpickle_fallback: bool = True)[source]
Bases:
StorageInterface
- class pyiron_workflow.storage.StorageInterface[source]
Bases:
ABCAbstract base class defining the interface for saving, loading, and managing node storage.
Public methods accept **kwargs so that specific implementations can have extra behaviour. In general, whatever can be set for the kwargs should also be able to be specified at initialization as a default, so that users can configure a storage back-end the way they want and then run it from there – kwargs are just exposed to make special instances of use easier.
- delete(node: Node | None = None, filename: str | Path | None = None, delete_even_if_not_empty: bool = False, **kwargs)[source]
Delete a file associated with a node.
- Parameters:
node (Node | None) – The node whose associated file is to be deleted. Optional if filename is provided.
filename (str | Path | None) – The path to the file to delete (without file extension). Optional if the node is provided.
**kwargs – Additional keyword arguments.
- has_saved_content(node: Node | None = None, filename: str | Path | None = None, **kwargs) bool[source]
Check if a file has contents related to a node.
- Parameters:
node (Node | None) – The node to check. Optional if filename is provided.
filename (str | Path | None) – The path to the file to check (without file extension). Optional if the node is provided.
**kwargs – Additional keyword arguments.
- Returns:
True if contents exist, False otherwise.
- Return type:
bool
- load(node: Node | None = None, filename: str | Path | None = None, **kwargs) Node[source]
Load a node from a file.
- Parameters:
node (Node | None) – The node to load. Optional if filename is provided.
filename (str | Path | None) – The path to the file to load (without file extension). Uses the canonical filename based on the node’s lexical path instead if this is None.
**kwargs – Additional keyword arguments.
- Returns:
The loaded node.
- Return type:
- exception pyiron_workflow.storage.TypeNotFoundError[source]
Bases:
ImportErrorRaised when you try to save a node, but importing its module and class give something other than its type.
- pyiron_workflow.storage.available_backends(backend: Literal['h5bag', 'pickle'] | StorageInterface | None = None, only_requested: bool = False) Generator[StorageInterface, None, None][source]
A generator for accessing available
StorageInterfaceinstances, starting with the one requested.- Parameters:
backend (BackendIdentifier | StorageInterface | None) – The interface to yield first.
only_requested (bool) – Stop after yielding whatever was specified by :param:`backend`.
- Yields:
StorageInterface – An interface for serializing
Node.