hyrax
Submodules
Classes
Overall class that represents an interface into hyrax. Currently this encapsulates a configuration and is |
Functions
|
Log a runtime configuration. |
|
Given a configuration dictionary and a registry dictionary, attempt to return |
|
Dynamically import a module from a string. |
|
Add a class to a given registry dictionary. |
Package Contents
- log_runtime_config(runtime_config: ConfigDict, output_path: pathlib.Path, file_name: str = 'runtime_config.toml')[source]
Log a runtime configuration.
- Parameters:
runtime_config (ConfigDict) – A ConfigDict object containing runtime configuration values.
output_path (str) – The path to put the config file
file_name (str, Optional) – Optional name for the config file, defaults to “runtime_config.toml”
- class Hyrax(*, config_file: pathlib.Path | str | None = None, setup_logging: bool = True)[source]
Overall class that represents an interface into hyrax. Currently this encapsulates a configuration and is the external interface to all verbs in a programmatic or notebook context.
CLI functions in hyrax_cli are implemented by calling this class
Initialize hyrax. Always applies the default config, and merges it with any provided config file.
- Parameters:
config_file (Union[Path, str], optional) – filename or pathlib.Path to a config file, by default None
setup_logging (bool, optional) – Logging setup for a hyrax object is global loggers named “hyrax.*” If you want to turn off logging config for “hyrax.*” python loggers, pass False here. By default True.
Notes
You may want to set
setup_loggingmanually if: - You have multiple Hyrax objects in your application or notebook, and would like to control which of their logging configs is used globally. By creating one of your objects with setup_logging=True and the others with setup_logging=False, the single object created with setup_logging=True will control where the log is emitted to and what the threshold level is. - You have another library which needs overall control over python logging’s config, and you do not want hyrax to alter any global logging config. In this case you should always pass setup_logging=False. Hyrax will still send logs into python logging; however, the other system will be responsible for where those logs are emitted, and what the threshold level is.You may want to leave the default of setup_logging=True if: - You have a single Hyrax object in use at any time. This is true in most notebook like environments.
- config_manager
- config
- logger
- _initialize_log_handlers()[source]
Private initialization helper, Adds handlers and level setting to the global self.logger object
- raw_data_dimensions() tuple[list[int], list[int]][source]
Gives the dimensions of underlying data that forms input to the training, and inference steps. This is the raw data that the data loader must normalize to the model
- Returns:
widths and heights of all images available locally.
- Return type:
tuple[list[int],list[int]]
- get_or_load_class(config: dict, registry: dict[str, T] | None = None) T | Any[source]
Given a configuration dictionary and a registry dictionary, attempt to return the requested class either from the registry or by dynamically importing it.
- Parameters:
config (dict) – The configuration dictionary. Must contain the key, “name”.
registry (dict) – The registry dictionary of <class name> : <class type> pairs.
- Returns:
The returned class to be instantiated
- Return type:
type
- Raises:
ValueError – User failed to specify a class to load in the runtime configuration. No name key was found in the config.
- import_module_from_string(module_path: str) Any[source]
Dynamically import a module from a string.
- Parameters:
module_path (str) – The import spec for the model class. Should be of the form: “module.submodule.class_name”
- Returns:
model_cls – The model class.
- Return type:
type
- Raises:
AttributeError – If the model class is not found in the module that is loaded.
ModuleNotFoundError – If the module is not found using the provided import spec.