Fix download-structures entry point (crashes for every user)#111
Open
paxcalpt wants to merge 2 commits into
Open
Fix download-structures entry point (crashes for every user)#111paxcalpt wants to merge 2 commits into
paxcalpt wants to merge 2 commits into
Conversation
download_suggested_structures() crashed for every user: - Read data["id"]/data["title"], but structure YAMLs nest these under a `model:` mapping with a capital ID. Now reads data["model"]["ID"] and data["model"]["title"], matching experiments.py. - Defaulted data_path to "data" (./data/structures), which does not exist. Now defaults to the installed package configs dir via vlab4mic.__file__. - Template skip used an exact "_template" match, but the file is _template_.yaml; it slipped through and crashed. Now uses startswith. Also fix stale makefile help text (supramolsim -> vlab4mic) and add tests/test_download.py covering the default path, the model: nesting, and a network-mocked end-to-end skip run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes the download-structures console script which crashed for all users due to three bugs: wrong YAML key paths, an invalid default data path, and a faulty template-skip check. Also corrects stale help text in the makefile and adds tests covering the fixes.
Changes:
- Read structure metadata from the nested
model.ID/model.titlekeys and defaultdata_pathto the installed package'sconfigsdirectory. - Skip the
_template_.yamlfile viastartswith("_template")instead of an exact stem match. - Add tests for path resolution, YAML schema expectations, and a network-mocked end-to-end run.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vlab4mic/download.py | Fix YAML key access, default path resolution, and template skip predicate. |
| tests/test_download.py | New tests validating default path, nested-key schema, and skip-existing behavior without network. |
| makefile | Update stale help text from supramolsim.download to vlab4mic.download. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| def download_suggested_structures(data_path: str = "data") -> None: | ||
| def download_suggested_structures(data_path: str = None) -> None: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #111 +/- ##
==========================================
+ Coverage 67.72% 67.96% +0.24%
==========================================
Files 28 28
Lines 5084 5088 +4
==========================================
+ Hits 3443 3458 +15
+ Misses 1641 1630 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
`data_path: str = None` is implicit-optional, which modern mypy flags by default. Annotate as `Optional[str]` to match the None default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The
download-structuresconsole script (declared inpyproject.tomlasvlab4mic.download:download_suggested_structures) crashes for every user.Fixes —
src/vlab4mic/download.pyWrong YAML keys. The function read
data["id"]/data["title"], but the structure YAMLs nest these under amodel:mapping with a capitalID(e.g.7R5K.yaml). This raisedKeyErroron every file. Now readsdata["model"]["ID"]/data["model"]["title"], consistent withexperiments.py.Wrong default path. Default
data_path="data"resolved to./data/structures, which doesn't exist. Now defaults to the installed package configs dir derived fromvlab4mic.__file__, so the command works out of the box. A customdata_pathis still honoured.Template not skipped. The skip used
filename.stem == "_template", but the file is_template_.yaml(stem_template_), so it slipped through and crashed (it has lowercase emptyid:and notitle:). Now usesstartswith("_template").Other
makefile: stale help textsupramolsim.download:...→vlab4mic.download:....tests/test_download.py: covers the default path resolution, themodel:nesting (and absence of the old flat keys), and a network-mocked end-to-end run that skips existing.cifs without error.Verification
.cifs exist, and a missing.cifproduces the correcthttps://files.rcsb.org/download/<ID>.cifURL.🤖 Generated with Claude Code