-
Notifications
You must be signed in to change notification settings - Fork 8
feat(eval): discover trials from job metadata #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
manzuoni-astera
wants to merge
3
commits into
diff-use:main
Choose a base branch
from
manzuoni-astera:michaelanzuoni/issue-213-trial-metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| """Tests for metadata-backed grid-search trial discovery.""" | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
|
|
||
| from sampleworks.eval.grid_search_eval_utils import load_job_metadata, scan_grid_search_results | ||
|
|
||
|
|
||
| def test_scan_grid_search_results_prefers_job_metadata(tmp_path) -> None: | ||
| """Trial identity and input paths come from recorded job metadata.""" | ||
| trial_dir = tmp_path / "1ABC_0.5occA_0.5occB" / "wrong_model" / "wrong_scaler" / "ens1_gw0.1" | ||
| trial_dir.mkdir(parents=True) | ||
| (trial_dir / "refined.cif").write_text("data_test") | ||
| metadata = { | ||
| "protein": "1ABC", | ||
| "model_name": "boltz2", | ||
| "method": "MD", | ||
| "guidance_type": "pure_guidance", | ||
| "ensemble_size": 8, | ||
| "step_size": 0.25, | ||
| "altloc_occupancies": {"A": 0.25, "B": 0.75}, | ||
| "structure": "/inputs/1abc.cif", | ||
| "density": "/inputs/1abc.ccp4", | ||
| "resolution": 1.8, | ||
| } | ||
| (trial_dir / "job_metadata.json").write_text(json.dumps(metadata)) | ||
|
|
||
| trials = scan_grid_search_results(trial_dir, current_depth=4, target_depth=4) | ||
|
|
||
| assert len(trials) == 1 | ||
| trial = trials[0] | ||
| assert trial.protein == "1ABC" | ||
| assert trial.model == "boltz2" | ||
| assert trial.method == "MD" | ||
| assert trial.scaler == "pure_guidance" | ||
| assert trial.ensemble_size == 8 | ||
| assert trial.guidance_weight == 0.25 | ||
| assert trial.altloc_occupancies == {"A": 0.25, "B": 0.75} | ||
| assert trial.input_structure_path == Path("/inputs/1abc.cif") | ||
| assert trial.density_path == Path("/inputs/1abc.ccp4") | ||
| assert trial.resolution == 1.8 | ||
|
|
||
|
|
||
| def test_load_job_metadata_rejects_non_object_json(tmp_path) -> None: | ||
| """Metadata arrays are ignored rather than breaking trial discovery.""" | ||
| (tmp_path / "job_metadata.json").write_text("[]") | ||
|
|
||
| assert load_job_metadata(tmp_path) is None | ||
|
|
||
|
|
||
| def test_scan_uses_path_fallback_for_empty_metadata_values(tmp_path) -> None: | ||
| """Null or empty metadata fields do not replace usable path metadata.""" | ||
| trial_dir = tmp_path / "1ABC_1.0occA" / "boltz2_MD" / "pure_guidance" / "ens8_gw0.1" | ||
| trial_dir.mkdir(parents=True) | ||
| (trial_dir / "refined.cif").write_text("data_test") | ||
| (trial_dir / "job_metadata.json").write_text( | ||
| json.dumps({"protein": None, "model": None, "method": "", "ensemble_size": "8.0"}) | ||
| ) | ||
|
|
||
| trials = scan_grid_search_results(trial_dir, current_depth=4, target_depth=4) | ||
|
|
||
| assert len(trials) == 1 | ||
| assert trials[0].protein == "1abc" | ||
| assert trials[0].model == "boltz2" | ||
| assert trials[0].method == "MD" | ||
| assert trials[0].ensemble_size == 8 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.