Architectures¶
Utility functions to detect architecture and verify their names in metatrain.
- metatrain.utils.architectures.check_architecture_name(name: str) None[source]¶
Check if the requested architecture is available.
If the architecture is not found an
ValueError()is raised. If an architecture with the same name as an experimental or deprecated architecture exist, this architecture is suggested. If no architecture exist the closest architecture is given to help debugging typos.- Parameters:
name (str) – name of the architecture
- Raises:
ValueError – if the architecture is not found
- Return type:
None
- metatrain.utils.architectures.check_architecture_options(name: str, options: Dict) None[source]¶
Verifies that an options instance only contains valid keys
If the architecture developer does not provide a validation scheme the
optionswill not checked.
- metatrain.utils.architectures.get_architecture_name(path: str | Path) str[source]¶
Name of an architecture based on path to pointing inside an architecture.
The function should be used to determine the
ARCHITECTURE_NAMEbased on the name of the folder.- Parameters:
path (str | Path) – absolute path of the architecture directory
- Returns:
architecture name
- Raises:
ValueError – if
pathdoes not point to a valid architecture directory.- Return type:
See also
get_architecture_path()to get the relative path within the metatrain project of an architecture name.
- metatrain.utils.architectures.import_architecture(name: str) ModuleType[source]¶
Import an architecture.
- Parameters:
name (str) – name of the architecture
- Raises:
ImportError – if the architecture dependencies are not met
- Returns:
Imported architecture module
- Return type:
- metatrain.utils.architectures.get_architecture_path(name: str) Path[source]¶
Return the relative path to the architecture directory.
Path based on the
namewithin the metatrain project directory.- Parameters:
name (str) – name of the architecture
- Returns:
path to the architecture directory
- Return type:
See also
get_architecture_name()to get the name based on an absolute path of an architecture.