Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Remove LSB_JOBID from env when using eclrun
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreso committed Jan 27, 2021
1 parent 499db41 commit 38752a3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/res/fm/ecl/ecl100_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ eclrun_env:
SLBSLS_LICENSE_FILE: [email protected]
ECLPATH: /path/to/ecl
PATH: /path/to/ecl/macros
LSB_JOBID: null
5 changes: 5 additions & 0 deletions python/res/fm/ecl/ecl300_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ env:
F_UFMTENDIAN: big
ARCH: x86_64

eclrun_env:
SLBSLS_LICENSE_FILE: [email protected]
ECLPATH: /path/to/ecl
PATH: /path/to/ecl/macros
LSB_JOBID: null
6 changes: 6 additions & 0 deletions python/res/fm/ecl/ecl_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def _get_run_env(self, eclrun_env):
env["PATH"] = eclrun_env["PATH"] + os.pathsep + env["PATH"]
eclrun_env.pop("PATH")

for k, v in eclrun_env.copy().items():
if v is None:
if k in env:
env.pop(k)
eclrun_env.pop(k)

env.update(eclrun_env)
return env

Expand Down
38 changes: 38 additions & 0 deletions tests/res/fm/test_ecl_run_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import yaml
import pytest
import re
import json
from unittest import mock

from ecl.summary import EclSum
from ecl.util.test import TestAreaContext
Expand Down Expand Up @@ -54,6 +56,7 @@ def _eclrun_conf():
"ECLPATH": "/prog/res/ecl/grid",
"PATH": "/prog/res/ecl/grid/macros",
"F_UFMTENDIAN": "big",
"LSB_JOB_ID": None,
}
}

Expand All @@ -63,6 +66,41 @@ def init_eclrun_config(self):
f.write(yaml.dump(conf))
self.monkeypatch.setenv("ECL100_SITE_CONFIG", "ecl100_config.yml")

@tmpdir()
@mock.patch.dict(os.environ, {"LSB_JOBID": "some-id"})
def test_env(self):
self.init_eclrun_config()
with open("eclrun", "w") as f, open("DUMMY.DATA", "w"):
f.write(
"""#!/usr/bin/env python
import os
import json
with open("env.json", "w") as f:
json.dump(dict(os.environ), f)
"""
)
os.chmod("eclrun", os.stat("eclrun").st_mode | stat.S_IEXEC)
ecl_config = Ecl100Config()
eclrun_config = EclrunConfig(ecl_config, "2019.3")
ecl_run = EclRun("DUMMY", None, check_status=False)
with mock.patch.object(
ecl_run, "_get_run_command", mock.MagicMock(return_value="./eclrun")
):
ecl_run.runEclipse(eclrun_config=eclrun_config)
with open("env.json") as f:
run_env = json.load(f)

eclrun_env = self._eclrun_conf()["eclrun_env"]
for k, v in eclrun_env.items():
if v is None:
assert k not in run_env
continue

if k == "PATH":
assert run_env[k].startswith(v)
else:
assert v == run_env[k]

@tmpdir()
@pytest.mark.equinor_test
def test_run(self):
Expand Down

0 comments on commit 38752a3

Please sign in to comment.