Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions alphapulldown/folding_backend/alphafold3_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ def write_seed_outputs(

def write_fold_outputs(output_dir: os.PathLike[str] | str, job_name: str) -> None:
"""Copy the best ranked sample under the job name, with the terms of use: the same
bytes AlphaFold 3 writes there, also for samples of an interrupted earlier run."""
bytes AlphaFold 3 writes there, also for samples of an interrupted earlier run.

Without ranked samples this raises rather than returns: the fold has no model, and
post-processing it to the end would record it complete for ``--allow_resume`` to skip.
"""
best = af3_best_sample_dir(output_dir)
if best is None:
logging.warning(f'No ranked samples in {output_dir}; writing no best model.')
return
raise FileNotFoundError(
f'No ranked samples in {output_dir}: no model to write under {job_name}.'
)
for name in _SAMPLE_OUTPUTS:
with open(os.path.join(output_dir, best, name), 'rb') as source, open_atomic(
os.path.join(output_dir, f'{job_name}_{name}'), 'wb'
Expand Down
11 changes: 11 additions & 0 deletions test/unit/test_alphafold2_backend_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,3 +2105,14 @@ def test_af2_predict_reports_an_option_no_backend_takes(af2_backend_module):
assert list(predict(**common, num_diffusion_samples=5, crosslinks=None)) == []
with pytest.raises(ValueError, match="debug_msa"):
list(predict(**common, debug_msa=True))


def test_an_unreadable_json_left_by_an_older_version_is_ignored(
af2_backend_module, tmp_path, caplog
):
# Truncated by a run killed while writing it, before writes were atomic.
path = tmp_path / "timings.json"
path.write_text('{"predict_and_compile_model_1": 12.', encoding="utf-8")

assert af2_backend_module._read_from_json_if_exists(str(path)) == {}
assert "Ignoring unreadable" in caplog.text
Loading
Loading