def start(): r""" Starts the experiment. Run it using ``with`` statement and it will monitor and report, experiment completion and exceptions. """ global _load_run_uuid global _load_checkpoint return _experiment_singleton().start(run_uuid=_load_run_uuid, checkpoint=_load_checkpoint)
def save_numpy(name: str, array: np.ndarray): r""" Saves a single numpy array. This is used to save processed data. """ numpy_path = Path(_experiment_singleton().run.numpy_path) if not numpy_path.exists(): numpy_path.mkdir(parents=True) file_name = name + ".npy" np.save(str(numpy_path / file_name), array)
def get_uuid(): r""" Returns the UUID of the current experiment run """ return _experiment_singleton().run.uuid
def save_checkpoint(): r""" Saves model checkpoints """ _experiment_singleton().save_checkpoint()
def add_model_savers(savers: Dict[str, ModelSaver]): _experiment_singleton().checkpoint_saver.add_savers(savers)
def distributed(rank: int, world_size: int): _experiment_singleton().distributed(rank, world_size)
def start(): r""" Starts the experiment. """ _experiment_singleton().start()
def calculate_configs(*args): r""" Calculate configurations This has multiple overloads .. function:: calculate_configs(configs_dict: Dict[str, any]) :noindex: .. function:: calculate_configs(configs_dict: Dict[str, any], configs_override: Dict[str, any]) :noindex: .. function:: calculate_configs(configs: BaseConfigs) :noindex: .. function:: calculate_configs(configs: BaseConfigs, run_order: List[Union[List[str], str]]) :noindex: .. function:: calculate_configs(configs: BaseConfigs, *run_order: str) :noindex: .. function:: calculate_configs(configs: BaseConfigs, configs_override: Dict[str, any]) :noindex: .. function:: calculate_configs(configs: BaseConfigs, configs_override: Dict[str, any], run_order: List[Union[List[str], str]]) :noindex: .. function:: calculate_configs(configs: BaseConfigs, configs_override: Dict[str, any], *run_order: str) :noindex: Arguments: configs (BaseConfigs, optional): configurations object configs_dict (Dict[str, any], optional): a dictionary of configs configs_override (Dict[str, any], optional): a dictionary of configs to be overridden run_order (List[Union[str, List[str]]], optional): list of configs to be calculated and the order in which they should be calculated. If not provided all configs will be calculated. """ configs_override: Optional[Dict[str, any]] = None run_order: Optional[List[Union[List[str], str]]] = None idx = 1 if isinstance(args[0], BaseConfigs): if idx < len(args) and isinstance(args[idx], dict): configs_override = args[idx] idx += 1 if idx < len(args) and isinstance(args[idx], list): run_order = args[idx] if len(args) != idx + 1: raise RuntimeError("Invalid call to calculate configs") _experiment_singleton().calc_configs(args[0], configs_override, run_order) else: if idx == len(args): _experiment_singleton().calc_configs(args[0], configs_override, run_order) else: run_order = list(args[idx:]) for key in run_order: if not isinstance(key, str): raise RuntimeError("Invalid call to calculate configs") _experiment_singleton().calc_configs(args[0], configs_override, run_order) elif isinstance(args[0], dict): if idx < len(args) and isinstance(args[idx], dict): configs_override = args[idx] idx += 1 if idx != len(args): raise RuntimeError("Invalid call to calculate configs") _experiment_singleton().calc_configs_dict(args[0], configs_override) else: raise RuntimeError("Invalid call to calculate configs")