mlwiz

mlwiz.util

General-purpose helper functions for MLWiz.

Includes dotted-path resolution, config parsing helpers, and atomic dill serialization utilities.

mlwiz.util.atomic_dill_save(data: object, filepath: str) object

Saves a dill object to a file. :param data: the dill object to save :param filepath: the path to the dill object to save

mlwiz.util.dill_load(filepath: str) object

Loads a dill file. :param filepath: the path to the dill file :return: an object

mlwiz.util.return_class_and_args(config: dict, key: str, return_class_name: bool = False) Tuple[Callable[[...], object], dict]

Returns the class and arguments associated to a specific key in the configuration file.

Parameters:
  • config (dict) – the configuration dictionary

  • key (str) – a string representing a particular class in the configuration dictionary

  • return_class_name (bool) – if True, returns the class name as a string rather than the class object

Returns:

a tuple (class, dict of arguments), or (None, None) if the key is not present in the config dictionary

mlwiz.util.s2c(class_name: str) Callable[[...], object]

Converts a dotted path to the corresponding class

Parameters:

class_name (str) – dotted path to class name

Returns:

the class to be used