From 5c4ac3fae6ec7bc5d5b70836a88aba979a59730b Mon Sep 17 00:00:00 2001 From: Cathal O'Brien Date: Wed, 4 Dec 2024 15:08:23 +0100 Subject: [PATCH] [PROFILER] dont crash if an env var isnt found (#180) * check env vars safely * changelog --- CHANGELOG.md | 1 + src/anemoi/training/train/profiler.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2453a374..7d20fda0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Keep it human-readable, your future self will thank you! ## [Unreleased](https://github.com/ecmwf/anemoi-training/compare/0.3.1...HEAD) ### Fixed - Not update NaN-weight-mask for loss function when using remapper and no imputer [#178](https://github.com/ecmwf/anemoi-training/pull/178) +- Dont crash when using the profiler if certain env vars arent set [#180](https://github.com/ecmwf/anemoi-training/pull/180) ### Added - Added a check for the variable sorting on pre-trained/finetuned models [#120](https://github.com/ecmwf/anemoi-training/pull/120) diff --git a/src/anemoi/training/train/profiler.py b/src/anemoi/training/train/profiler.py index 40dd50e7..817a98f1 100644 --- a/src/anemoi/training/train/profiler.py +++ b/src/anemoi/training/train/profiler.py @@ -57,8 +57,8 @@ def print_title() -> None: @staticmethod def print_metadata() -> None: - console.print(f"[bold blue] SLURM NODE(s) {os.environ['HOST']} [/bold blue]!") - console.print(f"[bold blue] SLURM JOB ID {os.environ['SLURM_JOB_ID']} [/bold blue]!") + console.print(f"[bold blue] SLURM NODE(s) {os.getenv('SLURM_JOB_NODELIST', '')} [/bold blue]!") + console.print(f"[bold blue] SLURM JOB ID {os.getenv('SLURM_JOB_ID', '')} [/bold blue]!") console.print(f"[bold blue] TIMESTAMP {datetime.now(timezone.utc).strftime('%d/%m/%Y %H:%M:%S')} [/bold blue]!") @rank_zero_only