Conversation
|
Future Development: |
|
Review Notes: This should be good to go. It needs nwb schema to be merged first. |
Move 'child' and 'required_name' keys from @DocVal to __nwbfields__ where they belong, fixing the import-time crash: "docval for external_resources: keys ['child', 'required_name'] are not supported by docval" Also update nwb-schema submodule to latest herd branch (with dev merge conflict resolved). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The nwb-schema herd branch now includes hdmf-common-schema 1.9.0, which moved HERD from hdmf-experimental to hdmf-common. This is required so the NWB core namespace can find the HERD type. Note: This also requires hdmf >= 4.3.2 (unreleased) which bundles hdmf-common-schema 1.9.0. CI should install hdmf from dev branch until 4.3.2 is released. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Status update on this PRI've fixed two issues that were blocking this PR: 1. Fixed:
|
hdmf 5.0.0 will bundle hdmf-common-schema 1.9.0, which moved HERD from the hdmf-experimental namespace to hdmf-common. This is required for the NWB core namespace to resolve the HERD type used in nwb.file.yaml. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
depends on #2141 |
- Rename external_herd/internal_herd to _external_herd/_internal_herd - Use external_resources setter in __init__ to properly set parent - Remove reset_herd flag; check _external_herd is not None instead - Add docstrings to external_resources property, setter, and link_resources - Fix test assertions for HERD keys array shape (1-D not 2-D) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolved conflict in requirements.txt by taking newer versions from dev. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2111 +/- ##
=======================================
Coverage 95.10% 95.10%
=======================================
Files 29 29
Lines 2942 2943 +1
Branches 443 443
=======================================
+ Hits 2798 2799 +1
Misses 86 86
Partials 58 58
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…wb into herd_changes
- Fix grammar and enhance HERD changelog entry, add @rly - Use tempfile.TemporaryDirectory for test file cleanup - Use realistic session_description in tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Combine duplicate hdmf.common imports in file.py - Extract shared test setup into _create_nwbfile_with_herd helper - Fix import ordering, quote consistency, and indentation in tests - Use ISO 8601 duration format for age field Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Server requires at least version 0.74.0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
A HERD tutorial will be added as part of #1984 |
| If an external HERD has been linked via ``link_resources``, that object | ||
| is returned. Otherwise, the internal HERD set via ``__init__`` or the | ||
| setter is returned. | ||
| """ |
There was a problem hiding this comment.
With this setup, it looks like there is no way for a user to access the self._internal_herd once the self._external_herd is set. In general I think the whole _interal_herd and external_herd may be confusing. To clarify this a bit I would propose a few things:
- Rename
self._external_herdtoself._linked_herd. This to a) make the terminology consistent with how it used in the user-facing functions, e.g,.link_resources, and b) to avoid overloading the termexternalbecause it used both inexternal_resourcesto mean linking to things outside of the file andself._external_herdto mean data stored outside of the file. - Add a function
get_external_resources(bool linked)where a user can explictly say if they want the internal HERD or the linked HERD, (or maybe even a join of both, but that's not essential) - Add documentation for what
self._external_herdandself._internal_herdare. - To be consistent, we may not want to use the term
herdbut just stick withself._linked_external_resourcesandself._external_resources
BTW, why is _internal_herd needed? Wouldn't I access that via general_external_resources?
There was a problem hiding this comment.
Those suggestions make sense.
The automatic __-joined naming of fields only applies to untyped spec components. Allowing that for typed spec components that are then remapped in the NWBFile ObjectMapper would require a bit of refactoring because there would be multiple mappings for the same spec, and then order matters.
oruebel
left a comment
There was a problem hiding this comment.
Overall this looks good. Just some inconsistency in terminology
- Rename _external_herd/_internal_herd to _linked_external_resources/_external_resources - Rename herd parameter to external_resources in link_resources and setter - Add get_external_resources(linked) method to access specific HERD - Add test for get_external_resources Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove custom external_resources property/setter on NWBFile and rely on the auto-generated property from __nwbfields__. The HERDManager mixin is now an abstract interface in hdmf, and declaring external_resources in __nwbfields__ with child=True satisfies it. The external_resources attribute now always returns the owned HERD. Use get_external_resources(linked=True) to access a linked HERD. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| def link_resources(self, external_resources): | ||
| """Link an external HERD object as the external resources for this file. | ||
|
|
||
| The linked HERD will not be written on export; the original HERD | ||
| (if any) is preserved in the exported file. Use | ||
| ``get_external_resources(linked=True)`` to access the linked HERD. | ||
| """ | ||
| self._linked_external_resources = external_resources | ||
|
|
||
| def get_external_resources(self, linked=False): |
There was a problem hiding this comment.
@rly I'm wondering whether it would make sense to have this functionality to support linked external resources on the HERDManager base class instead. It just seems like this would be more generally useful functionality rather than being something that would be specific to NWBFile. We can leave this for now as is and make it a separate issue.
There was a problem hiding this comment.
That makes sense. I hadn't thought of that. Let's just handle it now. I'll update the HDMF PR and this one.
Remove link_resources and get_external_resources from NWBFile since these methods now live on the HERDManager base class in hdmf. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow HERD to be stored internally, but still allow external override
Future development:
On the surface to the user, HERD is a table and when you query before any I/O, you will see lists and tuples. Under the hood, HERD is written as a structured array and on read is no longer a list/tuple but a structured array. This was a bit surprising and so I spent some time to map over the array to a list on read in the get_item. However, this grew in complexity reaching __swap_refs in AbstractH5TableDataset. Without a clear easy solution, I am leaving this for future development. It is because of this the tests are structured the way they are in the asserts.
What was the reasoning behind this change? Please explain the changes briefly.
How to test the behavior?
Checklist
ruff check . && codespellfrom the source directory.