MCPcopy Create free account
hub / github.com/Victorletzelter/timeMCL / wrap

Function wrap

tsExperiments/utils/utils.py:153–181  ·  view source on GitHub ↗
(cfg: DictConfig)

Source from the content-addressed store, hash-verified

151 """
152
153 def wrap(cfg: DictConfig) -> Tuple[Dict[str, Any], Dict[str, Any]]:
154 # execute the task
155 try:
156 metric_dict, object_dict = task_func(cfg=cfg)
157
158 # things to do if exception occurs
159 except Exception as ex:
160 # save exception to `.log` file
161 log.exception("")
162
163 # some hyperparameter combinations might be invalid or cause out-of-memory errors
164 # so when using hparam search plugins like Optuna, you might want to disable
165 # raising the below exception to avoid multirun failure
166 raise ex
167
168 # things to always do after either success or exception
169 finally:
170 # display output dir path in terminal
171 log.info(f"Output dir: {cfg.paths.output_dir}")
172
173 # always close wandb run (even if exception occurs so multirun won't fail)
174 if find_spec("wandb"): # check if wandb is installed
175 import wandb
176
177 if wandb.run:
178 log.info("Closing wandb!")
179 wandb.finish()
180
181 return metric_dict, object_dict
182
183 return wrap
184

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected