-
Notifications
You must be signed in to change notification settings - Fork 3
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
ENH: add search term for retrieving Entries that are nested under an ancestor #108
Merged
shilorigins
merged 6 commits into
pcdshub:master
from
shilorigins:devagr/CSWOPS-66-ancestor-search-option
Dec 3, 2024
Merged
ENH: add search term for retrieving Entries that are nested under an ancestor #108
shilorigins
merged 6 commits into
pcdshub:master
from
shilorigins:devagr/CSWOPS-66-ancestor-search-option
Dec 3, 2024
Conversation
This file contains 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
shilorigins
added
enhancement
New feature or request
Core Client
Core functionality (Python Client) related issues
labels
Nov 21, 2024
shilorigins
force-pushed
the
devagr/CSWOPS-66-ancestor-search-option
branch
from
November 21, 2024 22:57
c8fe14d
to
452291f
Compare
shilorigins
force-pushed
the
devagr/CSWOPS-66-ancestor-search-option
branch
from
November 25, 2024 23:36
452291f
to
7a3a1f9
Compare
The new term uses a utility method FilestoreBackend._gather_reachable to check whether each entry matches the term. This method collects all Entries reachable from the ancestor, and the result is cached for the duration of the search.
.save_entry didn't flatten the new entry when inserting it into the backend cache, and the cache is reconstructed from _root in every _load_or_initialize call. This means once the filestore_backend fixture is set up, the final entry's children aren't accessible from the cache until _load_or_initialize is called. Flattening new entries in .save_entry fixes this issue.
shilorigins
force-pushed
the
devagr/CSWOPS-66-ancestor-search-option
branch
from
November 25, 2024 23:41
7a3a1f9
to
500521b
Compare
tangkong
previously approved these changes
Nov 26, 2024
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.
Looks good to me 👍 I left suggestions for a slightly expanded test and a more permissive type hint, but I think the core of this is hard to disagree with. I imagine this gets refactored a bit with the Visitor concept
tangkong
approved these changes
Dec 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Description
Add support for
ancestor
SearchTerm
toFilestoreBackend.search
Add
FilestoreBackend._gather_progeny
utility methodCloses #102
Motivation and Context
With an
Entry
in oneNestable
, it is impossible to retrieve the correspondingEntry
in anotherNestable
using the existingSearchTerms
. The attributes of the knownEntry
do not reliably correspond to attributes of the desiredEntry
, other than the.pv_name
or.title
, so it is necessary to be able to limit searches toEntry
s that are nested under a knownNestable
.A concrete use case is comparing snapshots. For each PV in the first snapshot, the corresponding PV must be found in the second snapshot using only the PV string. This becomes possible using the new search term.
The current implementation uses a utility method to gather all
Entry
s nested under an ancestorEntry
. This enables caching the result usingfunctools.cache
, which lets us avoid:Calling
cache
directly rather than as a decorator limits the caching to eachFilestoreBackend.search
call, so changes to the data between searches are reflected properly. I believe each cache should be garbage collected after each search, but I haven't been able to verify this yet.How Has This Been Tested?
A unit test in
tests/test_backend
and an integration test intests/test_client
.Where Has This Been Documented?
Pre-merge checklist
docs/pre-release-notes.sh
and created a pre-release documentation page