mml.core.scripts.utils
- class LearningPhase[source]
Bases:
StrEnumAn enumeration.
- TEST = 'test'
- TRAIN = 'train'
- VAL = 'val'
- __new__(value)
- static all_phases() List[LearningPhase][source]
- class Singleton[source]
Bases:
objectThe actual Singleton class to inherit from. Make sure to have Singleton as the leftmost base class.
- classmethod clear_instance() None[source]
Clears the cached instance of the singleton. Be aware, that this does not affect references to the “old” instance, but any further call of “instance” or Class() will create a new instance, that will be returned from any further call.
- Returns:
- classmethod instance(*args: Any, **kwargs: Any) TSingleton[source]
Convenience function that does the same as Class(), but makes the singleton property more readable in code.
- Parameters:
args – any init args, be aware that these are ignored if there already exists an instance
kwargs – any init kwargs, be aware that these are ignored if there already exists an instance
- Returns:
either a new instance (first call) or a reference to the already existing instance
- ask_confirmation(message: str = '') bool[source]
Lets user confirm a message.
- Parameters:
message – The message to be confirmed
- Returns:
bool indicating whether the message has been confirmed
- Return type:
- class catch_time[source]
Bases:
objectTiming utility context manager. Usage:
access time via timer.pretty_time afterward, e.g. for logging.
- load_env() None[source]
Loads the mml.env variables. Make sure to have renamed and adapted example.env beforehand. If an environment variable MML_ENV_PATH is given this file is preferred, else the default path inside the mml package is used.
- Returns:
None
- load_mml_plugins() None[source]
This function allows to load mml plugins. These are other installed packages that provide a ‘mml.plugins’ entry point. See https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata for details on this mechanism.