(cfg)
| 33 | |
| 34 | |
| 35 | def create_working_directory(cfg): |
| 36 | slurm_job_id = os.environ.get("SLURM_JOB_ID", "null") |
| 37 | file_name = "%s_working_dir.tmp" % slurm_job_id |
| 38 | world_size = comm.get_world_size() |
| 39 | if world_size > 1 and not dist.is_initialized(): |
| 40 | comm.init_process_group("nccl", init_method="env://") |
| 41 | |
| 42 | if isinstance(cfg.task.get("model"), dict): |
| 43 | model_class = cfg.task.model["class"] |
| 44 | else: |
| 45 | model_class = "Placeholder" |
| 46 | working_dir = os.path.join(os.path.expanduser(cfg.output_dir), |
| 47 | cfg.task["class"], cfg.dataset["class"], model_class, slurm_job_id, |
| 48 | time.strftime("%Y-%m-%d-%H-%M-%S")) |
| 49 | |
| 50 | # synchronize working directory |
| 51 | if comm.get_rank() == 0: |
| 52 | with open(file_name, "w") as fout: |
| 53 | fout.write(working_dir) |
| 54 | os.makedirs(working_dir) |
| 55 | comm.synchronize() |
| 56 | if comm.get_rank() != 0: |
| 57 | with open(file_name, "r") as fin: |
| 58 | working_dir = fin.read() |
| 59 | comm.synchronize() |
| 60 | if comm.get_rank() == 0: |
| 61 | os.remove(file_name) |
| 62 | |
| 63 | os.chdir(working_dir) |
| 64 | return working_dir |
| 65 | |
| 66 | |
| 67 | def detect_variables(cfg_file): |
nothing calls this directly
no outgoing calls
no test coverage detected