def run( overrides: Sequence[str], mode: heyhi.ModeType, adhoc: bool = False, force_override_exp_id: Optional[str] = None, force_override_tag: Optional[str] = None, ) -> heyhi.ExperimentDir: """Computes the task locally of remotely if neeeded in the mode. The function checks the exp_handle first to detect whether the experiment is running, dead, or dead. Depending on that and the mode the function may kill the job, wipe the exp_handle, start a computation or do none of this. See heyhi.handle_dst for how the modes are handled. The computation may run locally or on the cluster depending on the launcher config section. In both ways main(cfg) with me executed with the final config with all overrides and substitutions. """ cfg = pathlib.Path("conf/c02_selfplay/poker_sp.yaml") heyhi.setup_logging() logging.info("Config: %s", cfg) logging.info("Overrides: %s", overrides) if not CFG_PATH.exists(): CFG_PATH.mkdir(exist_ok=True, parents=True) exp_handle, need_run = heyhi.handle_dst( EXP_DIR, mode, cfg, overrides, adhoc, force_override_exp_id=force_override_exp_id, force_override_tag=force_override_tag, ) logging.info("Exp dir: %s", exp_handle.exp_path) logging.info("Job status [before run]: %s", exp_handle.get_status()) if need_run: print("------ ", cfg) main() #heyhi.run_with_config(main, exp_handle, cfg, overrides, [CFG_PATH]) if exp_handle.is_done(): result = torch.load(exp_handle.result_path) if result is not None: simple_result = { k: v for k, v in result.items() if isinstance(v, (int, float, str)) } pprint.pprint(simple_result, indent=2) return exp_handle
def main(task, cfg): heyhi.setup_logging() logging.info("Cwd: %s", os.getcwd()) logging.info("Task: %s", task) logging.info("Cfg:\n%s", cfg) heyhi.log_git_status() logging.info("Is on slurm: %s", heyhi.is_on_slurm()) if heyhi.is_on_slurm(): logging.info("Slurm job id: %s", heyhi.get_slurm_job_id()) logging.info("Is master: %s", heyhi.is_master()) if task not in TASKS: raise ValueError("Unknown task: %s. Known tasks: %s" % (task, sorted(TASKS))) return TASKS[task](cfg)
def main(cfg): heyhi.setup_logging() logging.info("CWD: %s", os.getcwd()) logging.info("cfg:\n%s", cfg.pretty()) resource.setrlimit(resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) logging.info("resource.RLIMIT_CORE: %s", resource.RLIMIT_CORE) heyhi.log_git_status() logging.info("Is AWS: %s", heyhi.is_aws()) logging.info("is on slurm:%s", heyhi.is_on_slurm()) if heyhi.is_on_slurm(): logging.info("Slurm job id: %s", heyhi.get_slurm_job_id()) logging.info("Is master: %s", heyhi.is_master()) task = getattr(cfvpy.tasks, cfg.task) return task(cfg)
def main(cfg): print("HERHEHRHEHREHRHERHEHR") heyhi.setup_logging() logging.info("CWD: %s", os.getcwd()) logging.info("cfg:\n%s", cfg.pretty()) #resource.setrlimit( # resource.RLIMIT_CORE, (16, 16) #) logging.info("resource.RLIMIT_CORE: %s", resource.RLIMIT_CORE) heyhi.log_git_status() logging.info("Is AWS: %s", heyhi.is_aws()) logging.info("is on slurm:%s", heyhi.is_on_slurm()) if heyhi.is_on_slurm(): logging.info("Slurm job id: %s", heyhi.get_slurm_job_id()) logging.info("Is master: %s", heyhi.is_master()) #task = getattr(cfvpy.tasks, cfg.task) #return task(cfg) return cfvpy.tasks.selfplay(cfg)