def __enter__(self): try: config_dir, config_file = split_config_path(self.config_path) hydra = Hydra.create_main_hydra_file_or_module( calling_file=self.calling_file, calling_module=self.calling_module, config_dir=config_dir, strict=self.strict, ) self.hydra = hydra self.temp_dir = tempfile.mkdtemp() overrides = copy.deepcopy(self.overrides) overrides.append("hydra.run.dir={}".format(self.temp_dir)) self.job_ret = self.hydra.run( config_file=config_file, task_function=self, overrides=overrides, ) strip_node(self.job_ret.cfg, "hydra.run.dir") return self finally: GlobalHydra().clear()
def __enter__(self) -> "SweepTaskFunction": self.temp_dir = tempfile.mkdtemp() overrides = copy.deepcopy(self.overrides) assert overrides is not None overrides.append("hydra.sweep.dir={}".format(self.temp_dir)) try: config_dir, config_file = split_config_path(self.config_path) hydra = Hydra.create_main_hydra_file_or_module( calling_file=self.calling_file, calling_module=self.calling_module, config_dir=config_dir, strict=self.strict, ) self.returns = hydra.multirun( config_file=config_file, task_function=self, overrides=overrides ) finally: GlobalHydra().clear() return self
def __enter__(self): self.temp_dir = tempfile.mkdtemp() overrides = copy.deepcopy(self.overrides) overrides.append("hydra.sweep.dir={}".format(self.temp_dir)) try: config_dir, config_file = split_config_path(self.config_path) hydra = Hydra.create_main_hydra_file_or_module( calling_file=self.calling_file, calling_module=self.calling_module, config_dir=config_dir, strict=self.strict, ) self.returns = hydra.multirun( config_file=config_file, task_function=self, overrides=overrides ) flat = [item for sublist in self.returns for item in sublist] for ret in flat: strip_node(ret.cfg, "hydra.sweep.dir") finally: GlobalHydra().clear() return self