@@ -73,15 +73,19 @@ def _place_result(
7373 return result_json
7474
7575
76+ def _ensure_replica_dir (results_dir : Path , tname : str , replica_id : int ) -> Path :
77+ """Create an empty replica directory (no result JSON) for auto-detect."""
78+ replica_dir = results_dir / tname / f"replica_{ replica_id } "
79+ replica_dir .mkdir (parents = True , exist_ok = True )
80+ return replica_dir
81+
82+
7683def _run (
7784 slurm_env : dict [str , Path ],
7885 * extra_args : str ,
7986 root : Path ,
80- replicas : int | None = None ,
8187) -> subprocess .CompletedProcess [str ]:
8288 cmd = ["bash" , str (CHECK_STATUS ), "-r" , str (root )]
83- if replicas is not None :
84- cmd += ["-n" , str (replicas )]
8589 cmd += list (extra_args )
8690 return subprocess .run (
8791 cmd ,
@@ -118,7 +122,7 @@ def test_valid_result_shows_ddg(
118122 ) -> None :
119123 _place_result (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 , valid = True )
120124
121- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
125+ result = _run (slurm_env , root = openfe_workspace ["root" ])
122126 assert result .returncode == 0
123127
124128 rows = _parse_rows (result .stdout )
@@ -137,7 +141,7 @@ def test_null_estimate_is_failed(
137141 ) -> None :
138142 _place_result (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 , valid = False )
139143
140- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
144+ result = _run (slurm_env , root = openfe_workspace ["root" ])
141145 assert result .returncode == 0
142146
143147 rows = _parse_rows (result .stdout )
@@ -152,7 +156,8 @@ class TestNoResultNoJob:
152156 def test_missing_result_is_failed (
153157 self , slurm_env : dict [str , Path ], openfe_workspace : dict [str , Path ]
154158 ) -> None :
155- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
159+ _ensure_replica_dir (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 )
160+ result = _run (slurm_env , root = openfe_workspace ["root" ])
156161 assert result .returncode == 0
157162
158163 rows = _parse_rows (result .stdout )
@@ -178,7 +183,8 @@ def test_active_job_in_squeue(
178183 self , slurm_env : dict [str , Path ], openfe_workspace : dict [str , Path ]
179184 ) -> None :
180185 self ._setup_active (slurm_env , openfe_workspace )
181- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
186+ _ensure_replica_dir (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 )
187+ result = _run (slurm_env , root = openfe_workspace ["root" ])
182188 assert result .returncode == 0
183189
184190 rows = _parse_rows (result .stdout )
@@ -191,7 +197,8 @@ def test_no_yaml_shows_zero_percent(
191197 self , slurm_env : dict [str , Path ], openfe_workspace : dict [str , Path ]
192198 ) -> None :
193199 self ._setup_active (slurm_env , openfe_workspace )
194- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
200+ _ensure_replica_dir (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 )
201+ result = _run (slurm_env , root = openfe_workspace ["root" ])
195202
196203 rows = _parse_rows (result .stdout )
197204 assert "0%" in rows [0 ]["info" ]
@@ -222,7 +229,7 @@ def test_yaml_progress(
222229 " estimated_time_remaining: 1 day, 12:00:00\n "
223230 )
224231
225- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
232+ result = _run (slurm_env , root = openfe_workspace ["root" ])
226233 rows = _parse_rows (result .stdout )
227234 assert "25.0%" in rows [0 ]["info" ]
228235 assert "ETA:" in rows [0 ]["info" ]
@@ -246,7 +253,8 @@ def test_error_on_duplicate_jobs(
246253 f"-o { root_abs } /results\n "
247254 )
248255
249- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
256+ _ensure_replica_dir (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 )
257+ result = _run (slurm_env , root = openfe_workspace ["root" ])
250258 assert result .returncode == 0
251259
252260 rows = _parse_rows (result .stdout )
@@ -264,9 +272,9 @@ def test_mixed_statuses(
264272 tname = "rbfe_A_complex_B_complex"
265273 _place_result (openfe_workspace ["results_dir" ], tname , 0 , valid = True )
266274 _place_result (openfe_workspace ["results_dir" ], tname , 1 , valid = False )
267- # replica 2: no result, no job
275+ _ensure_replica_dir ( openfe_workspace [ "results_dir" ], tname , 2 )
268276
269- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 3 )
277+ result = _run (slurm_env , root = openfe_workspace ["root" ])
270278 assert result .returncode == 0
271279
272280 rows = _parse_rows (result .stdout )
@@ -304,9 +312,9 @@ def test_restart_submits_failed(
304312 tname = "rbfe_A_complex_B_complex"
305313 _place_result (openfe_workspace ["results_dir" ], tname , 0 , valid = True )
306314 _place_result (openfe_workspace ["results_dir" ], tname , 1 , valid = False )
307- # replica 2: missing
315+ _ensure_replica_dir ( openfe_workspace [ "results_dir" ], tname , 2 )
308316
309- result = _run (slurm_env , "-R" , root = openfe_workspace ["root" ], replicas = 3 )
317+ result = _run (slurm_env , "-R" , root = openfe_workspace ["root" ])
310318 assert result .returncode == 0
311319
312320 sbatch_log = slurm_env ["sbatch" ].read_text ().strip ()
@@ -322,7 +330,8 @@ def test_restart_submits_failed(
322330 def test_no_restart_without_flag (
323331 self , slurm_env : dict [str , Path ], openfe_workspace : dict [str , Path ]
324332 ) -> None :
325- result = _run (slurm_env , root = openfe_workspace ["root" ], replicas = 1 )
333+ _ensure_replica_dir (openfe_workspace ["results_dir" ], "rbfe_A_complex_B_complex" , 0 )
334+ result = _run (slurm_env , root = openfe_workspace ["root" ])
326335 assert result .returncode == 0
327336
328337 sbatch_log = slurm_env ["sbatch" ].read_text ().strip ()
@@ -336,7 +345,7 @@ def test_missing_transforms_dir(self, slurm_env: dict[str, Path], tmp_path: Path
336345 empty = tmp_path / "empty"
337346 empty .mkdir ()
338347
339- result = _run (slurm_env , root = empty , replicas = 1 )
348+ result = _run (slurm_env , root = empty )
340349 assert result .returncode != 0
341350 assert "transformations directory not found" in result .stderr
342351
0 commit comments