Add specs/model_spec.md and enrich vgg11.py as agent reference material#9
Add specs/model_spec.md and enrich vgg11.py as agent reference material#9
Conversation
- Create specs/ directory with model_spec.md: a dense, agent-targeted reference covering the @hyrax_model decorator, constructor contract, all five batch methods, prepare_inputs, TOML config, Hyrax wiring, and common pitfalls - Expand vgg11.py class/method docstrings so the file serves as the canonical annotated example agents are directed to read https://claude.ai/code/session_01535J3bEqioGhVTVR7sdEN6
There was a problem hiding this comment.
Pull request overview
Adds agent-facing reference documentation for building Hyrax-compatible external PyTorch models, and upgrades the VGG11 example’s docstrings to serve as the annotated “canonical example” referenced by that spec.
Changes:
- Added
specs/model_spec.mddescribing the@hyrax_modelcontract, required batch methods,prepare_inputs, config conventions, and common pitfalls. - Expanded docstrings in
src/external_hyrax_example/models/vgg11.pyto document Hyrax integration requirements and per-batch method responsibilities.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/external_hyrax_example/models/vgg11.py |
Enriched docstrings/comments to explain Hyrax model integration and batch-method expectations. |
specs/model_spec.md |
New consolidated spec for agents implementing Hyrax-compatible models. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data_sample: A single batch tuple ``(images, labels)`` produced by | ||
| the dataset's ``prepare_inputs`` method. The first element must | ||
| be a float tensor of shape ``(N, C, H, W)``. The channel count |
There was a problem hiding this comment.
The docstring says data_sample is produced by the dataset's prepare_inputs method, but none of the datasets in this package define prepare_inputs (and this model defines VGG11.prepare_inputs). Consider rewording to reflect that Hyrax/model prepare_inputs produces the batch tuple passed as data_sample.
| data_sample: A single batch tuple ``(images, labels)`` produced by | |
| the dataset's ``prepare_inputs`` method. The first element must | |
| be a float tensor of shape ``(N, C, H, W)``. The channel count | |
| data_sample: A single batch tuple ``(images, labels)`` prepared for | |
| the model by Hyrax via ``prepare_inputs``. The first element must | |
| be a float tensor of shape ``(N, C, H, W)``. The channel count |
| # Infer input channels from the sample rather than hard-coding them. | ||
| # data_sample[0] is a batch of images with shape (N, C, H, W). | ||
| image_sample = data_sample[0] | ||
| batch_size, self.in_channels, width, height = image_sample.shape |
There was a problem hiding this comment.
image_sample.shape is documented as (N, C, H, W), but the unpacking uses width, height for the last two dims (and neither variable is used). Renaming these to height, width or using _ placeholders would avoid confusion about which dimension is which.
| batch_size, self.in_channels, width, height = image_sample.shape | |
| _, self.in_channels, _, _ = image_sample.shape |
|
|
||
| def __init__(self, config, data_sample=None): | ||
| """Basic initialization with architecture definition""" | ||
| """Initialise the VGG11 architecture. |
There was a problem hiding this comment.
Spelling inconsistency: this docstring uses "Initialise" while other docstrings in the package use "Initialize" (e.g. Galaxy10Dataset). Consider standardizing to "Initialize" for consistency.
| """Initialise the VGG11 architecture. | |
| """Initialize the VGG11 architecture. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9 +/- ##
=======================================
Coverage 25.00% 25.00%
=======================================
Files 2 2
Lines 72 72
=======================================
Hits 18 18
Misses 54 54 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
reference covering the @hyrax_model decorator, constructor contract,
all five batch methods, prepare_inputs, TOML config, Hyrax wiring,
and common pitfalls
canonical annotated example agents are directed to read
https://claude.ai/code/session_01535J3bEqioGhVTVR7sdEN6