Skip to content

Commit

Permalink
removed 2nd check on json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdorsch committed Aug 22, 2024
1 parent 349f536 commit 88b1766
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/common/schedulers/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,13 @@ def submit(self, submission_spec):

if submission_spec.job_env:
# convert to "key=value,key=value,.." for Slurm
try:
j = json.loads(submission_spec.job_env)
text = ""
for k, v in j.items():
text += f"{k}={v},"
text = text[:-1]
job_env = text
cmd.append(f"--export='{job_env}'")
except TypeError as te:
logger.error(f"Invalid JSON provided ({te}) in job_env "
f"({submission_spec.job_env})")
except json.decoder.JSONDecodeError as jde:
logger.error(f"Invalid JSON provided ({jde}) in job_env "
f"({submission_spec.job_env})")
except Exception as e:
logger.error(f"Invalid JSON provided ({e}) in job_env "
f"({submission_spec.job_env})")
j = json.loads(submission_spec.job_env)
text = ""
for k, v in j.items():
text += f"{k}={v},"
text = text[:-1]
job_env = text
cmd.append(f"--export='{job_env}'")

cmd += [f"--chdir='{submission_spec.job_dir}'"]
cmd += self._opts
Expand Down

0 comments on commit 88b1766

Please sign in to comment.