Skip to content

Fix download-structures entry point (crashes for every user)#111

Open
paxcalpt wants to merge 2 commits into
mainfrom
fix-download-structures-entrypoint
Open

Fix download-structures entry point (crashes for every user)#111
paxcalpt wants to merge 2 commits into
mainfrom
fix-download-structures-entrypoint

Conversation

@paxcalpt
Copy link
Copy Markdown
Contributor

Problem

The download-structures console script (declared in pyproject.toml as vlab4mic.download:download_suggested_structures) crashes for every user.

Fixes — src/vlab4mic/download.py

  1. Wrong YAML keys. The function read data["id"] / data["title"], but the structure YAMLs nest these under a model: mapping with a capital ID (e.g. 7R5K.yaml). This raised KeyError on every file. Now reads data["model"]["ID"] / data["model"]["title"], consistent with experiments.py.

  2. Wrong default path. Default data_path="data" resolved to ./data/structures, which doesn't exist. Now defaults to the installed package configs dir derived from vlab4mic.__file__, so the command works out of the box. A custom data_path is still honoured.

  3. 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 empty id: and no title:). Now uses startswith("_template").

Other

  • makefile: stale help text supramolsim.download:...vlab4mic.download:....
  • tests/test_download.py: covers the default path resolution, the model: nesting (and absence of the old flat keys), and a network-mocked end-to-end run that skips existing .cifs without error.

Verification

  • New tests pass (3 passed).
  • Direct run against the package's bundled configs: all titles parse, 0 network calls when .cifs exist, and a missing .cif produces the correct https://files.rcsb.org/download/<ID>.cif URL.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 29, 2026 20:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.title keys and default data_path to the installed package's configs directory.
  • Skip the _template_.yaml file via startswith("_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.

Comment thread src/vlab4mic/download.py Outdated


def download_suggested_structures(data_path: str = "data") -> None:
def download_suggested_structures(data_path: str = None) -> None:
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 29, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.96%. Comparing base (5a57c8c) to head (77dd281).

Files with missing lines Patch % Lines
src/vlab4mic/download.py 87.50% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants