| 20 | self.log_dir = self.setup_log_dir() |
| 21 | |
| 22 | def setup_log_dir(self, base=os.path.join(os.path.expanduser("~"), "csv_monitor")): |
| 23 | if self.enabled and dist.get_rank() == 0: |
| 24 | if self.output_path is not None: |
| 25 | log_dir = os.path.join(self.output_path, self.job_name) |
| 26 | # NOTE: This code path currently is never used since the default tensorboard_output_path is an empty string and not None. Saving it in case we want this functionality in the future. |
| 27 | else: |
| 28 | if "DLWS_JOB_ID" in os.environ: |
| 29 | infra_job_id = os.environ["DLWS_JOB_ID"] |
| 30 | elif "DLTS_JOB_ID" in os.environ: |
| 31 | infra_job_id = os.environ["DLTS_JOB_ID"] |
| 32 | else: |
| 33 | infra_job_id = "unknown-job-id" |
| 34 | |
| 35 | csv_monitor_dir_name = os.path.join(infra_job_id, "logs") |
| 36 | log_dir = os.path.join(base, csv_monitor_dir_name, self.job_name) |
| 37 | os.makedirs(log_dir, exist_ok=True) |
| 38 | return log_dir |
| 39 | |
| 40 | def write_events(self, event_list): |
| 41 | if self.enabled and dist.get_rank() == 0: |