Skip to content

sund.import_model

sund.import_model(model)

Imports the compiled class of an installed model.

Parameters:

Name Type Description Default
model str

Name of the model to import.

required

Raises:

Type Description
ValueError

Cannot find an installed model with name: 'model'

Returns:

Type Description
object

sund.Model class of the model.

Source code in src/sund/__init__.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def import_model(model:str) -> object:
    """Imports the compiled class of an installed model.

    Args:
        model (str): Name of the model to import.

    Raises:
        ValueError: Cannot find an installed model with name: 'model'

    Returns:
        sund.Model class of the model.
    """
    try:
        module = importlib.import_module("sund.Models." + model)
        return getattr(module, model)
    except ModuleNotFoundError:
        raise ValueError(f"Cannot find an installed model with name: '{model}'") from None