Skip to content

Commit 56e56e9

Browse files
authored
Merge pull request #1 from grassesi/fix-inference-launch_slurm
get stage info from environment variable.
2 parents 1d174d8 + a66c9c7 commit 56e56e9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/weathergen/run_train.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"""
1313

1414
import logging
15+
import os
1516
import pdb
1617
import sys
1718
import time
@@ -190,15 +191,20 @@ def train_with_args(argl: list[str], stream_dir: str | None):
190191

191192

192193
if __name__ == "__main__":
194+
try:
195+
stage = os.environ.get("WEATHERGEN_STAGE")
196+
except KeyError as e:
197+
msg = f"missing environment variable 'WEATHERGEN_STAGE'"
198+
raise ValueError(msg) from e
193199

194-
if any("train" in arg for arg in sys.argv):
200+
if stage == "train":
195201
# Entry point for slurm script.
196202
# Check whether --from_run_id passed as argument.
197203
if any("--from_run_id" in arg for arg in sys.argv):
198204
train_continue()
199205
else:
200206
train()
201-
elif any("inference" in arg for arg in sys.argv):
207+
elif stage == "inference":
202208
inference()
203209
else:
204210
logger.error("No stage was found.")

0 commit comments

Comments
 (0)