pisces.models.core.utils.load_model#
- pisces.models.core.utils.load_model(path: str | Path, registry: Registry | None = None) BaseModel [source]#
Load a
BaseModel
from an HDF5 file.The file is loaded by accessing the model metadata specifying the class name of the model. The class is then resolved using the provided
registry
.- Parameters:
path (
str
orPath
) – Path to the HDF5 file containing the model.registry (
Registry
, optional) – The registry class in which to look up the model class. If one is not provided, then the default registry is used. This should be sufficient in almost all cases as all the native models in Pisces are automatically registered here.
- Returns:
An instance of the resolved model class.
- Return type:
BaseModel
- Raises:
FileNotFoundError – If the path does not exist or is not a file.
ValueError – If the file is missing the “__model_class__” attribute.
LookupError – If the model class name is not present in the registry.
TypeError – If the resolved registry entry is not a BaseModel subclass.