-
Notifications
You must be signed in to change notification settings - Fork 43
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
Apply restrictions on parent tables in fetch_nwb #1086
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love the use of 'either self-restr or parent-restr will work' from the perspective that the function should be transparent about what it accepts and should probably do one or the other. I can see from the existing docstring that the intent was to accept parent restr, so we should fix the existing bug.
dicts have the property of not restricting when invalid, but invalid strings will return an empty set. Will this work for strings? Or does it depend on the null-restr effect of dicts?
Yeah, I think one of the early concessions made for user ease with the merge tables was this ability to restrict through for fetching. I wasn't aware about limitations of dicts vs strings. I'll test through permutations |
Thanks for catching the string restriction case @CBroz1. I have what I think is a working solution up now. I was testing for these cases: from spyglass.position.position_merge import PositionOutput
from spyglass.position.v1 import TrodesPosV1
merge_dict = (PositionOutput() & {"source":"TrodesPosV1"}).fetch("KEY",limit=1)[0]
merge_str = (PositionOutput() & merge_dict).restriction[0]
parent_dict =(PositionOutput().merge_get_parent(merge_dict)).fetch1("KEY")
parent_str = (TrodesPosV1() & parent_dict).restriction[0]
for restriction in [merge_dict,merge_str,parent_dict,parent_str]:
print(restriction)
(PositionOutput() & restriction).fetch_nwb()
PositionOutput().fetch_nwb(restriction)[0] The only case that doesn't run now is |
|
Sorry, that was poorly phrased on my part. What was that I agree that this isn't a case we should try to make work |
Co-authored-by: Chris Broz <Chris.Broz@ucsf.edu>
Description
Merge table efficiency #1017 created an issue in
Merge.fetch_nwb()
where if the passed restriction key applied to the parent table rather than the merge table, it wouldn't apply to the fetch_nwb call.Issue stems from this line, where
restriction
would have no effect if not specifying on theMerge
table (e.g. if key is not formerge_id
):Merge.fetch_nwb(restriction)
Checklist:
CITATION.cff
alter
snippet for release notes.CHANGELOG.md
with PR number and description.