|
48 | 48 | bs = SbatchSettings() |
49 | 49 | batch_rs = SrunSettings("echo", ["spam", "eggs"]) |
50 | 50 |
|
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) |
58 | 79 |
|
59 | 80 |
|
60 | 81 | @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"], |
63 | 85 | ) |
64 | | -def test_symlink(test_dir, entity): |
| 86 | +def test_symlink(test_dir, request, entity_fixture): |
65 | 87 | """Test symlinking historical output files""" |
| 88 | + entity = request.getfixturevalue(entity_fixture) |
66 | 89 | entity.path = test_dir |
67 | 90 | if entity.type == Ensemble: |
68 | 91 | for member in entity.models: |
@@ -93,15 +116,17 @@ def symlink_with_create_job_step(test_dir, entity): |
93 | 116 |
|
94 | 117 |
|
95 | 118 | @pytest.mark.parametrize( |
96 | | - "entity", |
| 119 | + "entity_fixture", |
97 | 120 | [ |
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", |
101 | 124 | ], |
| 125 | + ids=["ensemble", "orchestrator", "model"], |
102 | 126 | ) |
103 | | -def test_batch_symlink(entity, test_dir): |
| 127 | +def test_batch_symlink(request, entity_fixture, test_dir): |
104 | 128 | """Test symlinking historical output files""" |
| 129 | + entity = request.getfixturevalue(entity_fixture) |
105 | 130 | exp_dir = pathlib.Path(test_dir) |
106 | 131 | entity.path = test_dir |
107 | 132 | # For entities with sub-entities (like Orchestrator), set their paths too |
|
0 commit comments