Skip to content

Commit 525bc1e

Browse files
authored
Merge pull request #1519 from haddocking/analysis-issue
Makes sure directory exists before iterating into directory
2 parents a06d64f + 110ea75 commit 525bc1e

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22

3+
- 2026-04-15: Solve bug related to workflow restarting without analysis folder - Issue #1518
34
- 2026-04-14: Increase max number of timesteps in openmm module - BioExcel forum 6072
45
- 2026-04-12: Add possibility to run MD (mdref, mdscoring) without solvent - Issue #1512
56
- 2026-04-10: Corrected the definition of ion restraints in flexref - Issue #1510

src/haddock/modules/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ def get_module_steps_folders(
491491
list of str
492492
List containing strings with the names of the step folders.
493493
"""
494+
# Make sure the folder exists, otherwise this might throw an error
495+
if not Path(folder).exists():
496+
return []
494497
folders = (p.name for p in Path(folder).iterdir() if p.is_dir())
495498
steps = sorted(
496499
(f for f in folders if step_folder_regex_re.search(f)),

tests/test_gear_restart.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_preprocess_restart_from():
9393
f"{tmpdir}/{TRACEBACK_FOLDER}",
9494
f"{tmpdir}/{ANA_FOLDER}/2_caprieval_analysis",
9595
f"{tmpdir}/2_caprieval",
96+
f"{tmpdir}/data/2_caprieval",
9697
]
9798
expected_to_stay_there = [
9899
f"{tmpdir}/1_rigidbody",
@@ -104,3 +105,34 @@ def test_preprocess_restart_from():
104105
assert not os.path.exists(should_not_exist)
105106
for should_exist in expected_to_stay_there:
106107
assert os.path.exists(should_exist)
108+
109+
110+
def test_preprocess_restart_from_no_folders():
111+
"""Make sure there is no issue when removing folder when not present."""
112+
with tempfile.TemporaryDirectory() as tmpdir:
113+
# Build mimic of previous run directories
114+
module_dirs = ["topoaa", "rigidbody", "caprieval"]
115+
for module_index, module_name in enumerate(module_dirs):
116+
os.makedirs(f"{tmpdir}/data/{module_index}_{module_name}")
117+
os.makedirs(f"{tmpdir}/{module_index}_{module_name}")
118+
119+
# Test restart preprocessing function
120+
restart_run.preprocess_restart_from(Path(tmpdir), 2)
121+
122+
expected_not_to_be_there = [
123+
f"{tmpdir}/{TRACEBACK_FOLDER}",
124+
f"{tmpdir}/{ANA_FOLDER}/2_caprieval_analysis",
125+
f"{tmpdir}/2_caprieval",
126+
f"{tmpdir}/data/2_caprieval",
127+
f"{tmpdir}/{ANA_FOLDER}",
128+
]
129+
expected_to_stay_there = [
130+
f"{tmpdir}/1_rigidbody",
131+
f"{tmpdir}/data/1_rigidbody",
132+
f"{tmpdir}/0_topoaa",
133+
f"{tmpdir}/data/0_topoaa",
134+
]
135+
for should_not_exist in expected_not_to_be_there:
136+
assert not os.path.exists(should_not_exist)
137+
for should_exist in expected_to_stay_there:
138+
assert os.path.exists(should_exist)

0 commit comments

Comments
 (0)