Skip to content

Commit 95e9cb3

Browse files
committed
Reviewer's comments
1 parent 128f25e commit 95e9cb3

File tree

2 files changed

+44
-19
lines changed

2 files changed

+44
-19
lines changed

tests/test_output_files.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ def test_mutated_model_output(test_dir):
106106
def test_get_output_files_with_create_job_step(test_dir):
107107
"""Testing output files through _create_job_step"""
108108
exp_dir = pathlib.Path(test_dir)
109-
model.path = test_dir
109+
local_model = Model("test_model", params={}, path=test_dir, run_settings=rs)
110110
# Create metadata_dir to simulate consistent metadata structure
111111
metadata_dir = exp_dir / CONFIG.metadata_subdir
112-
step = controller._create_job_step(model, metadata_dir)
113-
expected_out_path = metadata_dir / (model.name + ".out")
114-
expected_err_path = metadata_dir / (model.name + ".err")
112+
step = controller._create_job_step(local_model, metadata_dir)
113+
expected_out_path = metadata_dir / (local_model.name + ".out")
114+
expected_err_path = metadata_dir / (local_model.name + ".err")
115115
assert step.get_output_files() == (str(expected_out_path), str(expected_err_path))
116116

117117

tests/test_symlinking.py

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,44 @@
4848
bs = SbatchSettings()
4949
batch_rs = SrunSettings("echo", ["spam", "eggs"])
5050

51-
ens = Ensemble("ens", params={}, run_settings=rs, batch_settings=bs, replicas=3)
52-
orc = Orchestrator(db_nodes=3, batch=True, launcher="slurm", run_command="srun")
53-
model = Model("test_model", params={}, path="", run_settings=rs)
54-
batch_model = Model(
55-
"batch_test_model", params={}, path="", run_settings=batch_rs, batch_settings=bs
56-
)
57-
anon_batch_model = _AnonymousBatchJob(batch_model)
51+
52+
@pytest.fixture
53+
def model_entity():
54+
return Model("test_model", params={}, path="", run_settings=rs)
55+
56+
57+
@pytest.fixture
58+
def ensemble_entity():
59+
return Ensemble("ens", params={}, run_settings=rs, batch_settings=bs, replicas=3)
60+
61+
62+
@pytest.fixture
63+
def orchestrator_entity():
64+
return Orchestrator(
65+
db_nodes=3, batch=True, launcher="slurm", run_command="srun"
66+
)
67+
68+
69+
@pytest.fixture
70+
def anon_batch_model_entity():
71+
batch_model = Model(
72+
"batch_test_model",
73+
params={},
74+
path="",
75+
run_settings=batch_rs,
76+
batch_settings=bs,
77+
)
78+
return _AnonymousBatchJob(batch_model)
5879

5980

6081
@pytest.mark.parametrize(
61-
"entity",
62-
[pytest.param(ens, id="ensemble"), pytest.param(model, id="model")],
82+
"entity_fixture",
83+
["ensemble_entity", "model_entity"],
84+
ids=["ensemble", "model"],
6385
)
64-
def test_symlink(test_dir, entity):
86+
def test_symlink(test_dir, request, entity_fixture):
6587
"""Test symlinking historical output files"""
88+
entity = request.getfixturevalue(entity_fixture)
6689
entity.path = test_dir
6790
if entity.type == Ensemble:
6891
for member in entity.models:
@@ -93,15 +116,17 @@ def symlink_with_create_job_step(test_dir, entity):
93116

94117

95118
@pytest.mark.parametrize(
96-
"entity",
119+
"entity_fixture",
97120
[
98-
pytest.param(ens, id="ensemble"),
99-
pytest.param(orc, id="orchestrator"),
100-
pytest.param(anon_batch_model, id="model"),
121+
"ensemble_entity",
122+
"orchestrator_entity",
123+
"anon_batch_model_entity",
101124
],
125+
ids=["ensemble", "orchestrator", "model"],
102126
)
103-
def test_batch_symlink(entity, test_dir):
127+
def test_batch_symlink(request, entity_fixture, test_dir):
104128
"""Test symlinking historical output files"""
129+
entity = request.getfixturevalue(entity_fixture)
105130
exp_dir = pathlib.Path(test_dir)
106131
entity.path = test_dir
107132
# For entities with sub-entities (like Orchestrator), set their paths too

0 commit comments

Comments
 (0)