-
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
Add Entry validation methods #28
Merged
shilorigins
merged 8 commits into
pcdshub:master
from
shilorigins:devagr/entry-validation
Jun 10, 2024
Merged
Add Entry validation methods #28
shilorigins
merged 8 commits into
pcdshub:master
from
shilorigins:devagr/entry-validation
Jun 10, 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
8 tasks
shilorigins
force-pushed
the
devagr/entry-validation
branch
2 times, most recently
from
May 17, 2024 15:38
32897b6
to
9a8122f
Compare
shilorigins
force-pushed
the
devagr/entry-validation
branch
3 times, most recently
from
May 31, 2024 16:04
61871f2
to
6381b7d
Compare
shilorigins
force-pushed
the
devagr/entry-validation
branch
from
May 31, 2024 16:13
6381b7d
to
e88904d
Compare
tangkong
reviewed
May 31, 2024
shilorigins
force-pushed
the
devagr/entry-validation
branch
2 times, most recently
from
June 4, 2024 22:05
17573c5
to
eb4cfa4
Compare
tangkong
reviewed
Jun 7, 2024
Entry.validate includes an apischema serialization roundtrip to enforce type checks Nestable validation includes cycle detection and ensuring Nestables aren't empty.
After confirming that a Collecion with a cycle doesn't validate, confirm whether the fixed Collection does validate. The initial implementation of Nestable.has_cycle used a mutable default parameter, meaning that call results could be influenced by previous calls. This addition tests that similar behaviour isn't re-introduced.
The previous implementation used one "parents" set for an entire tree, with each node mutating the set before its child calls and again before returning. Now each node creates a new set to pass to all of its children, limiting scope of each set.
Previously, Nestables would fail validation if they didn't have any children. Such entries are now considered valid, in case users want to record meta_pv values without any recording any restorable values.
shilorigins
force-pushed
the
devagr/entry-validation
branch
from
June 7, 2024 22:52
eb4cfa4
to
97331fa
Compare
I'm here a little late but everything here looks solid to me |
tangkong
approved these changes
Jun 10, 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.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
.validate()
method for allEntry
subclassesNestable
interface forCollection
andSnapshot
Motivation and Context
Validation ensures that
Entry
s are well formed before certain uses, such as inserting into a backend: close #11Adding validation methods to each
Entry
subclass leverages polymorphism to keep validation code close to the data being validated. This also keeps the client or backend agnostic to the type ofEntry
being validated.Entry.validate()
uses anapischema
serialization roundtrip to perform type checks. This implementation capturesValidationError
s and returnsFalse
if type checks fail, but I'd be open to leaving the exception if that's preferred. If a subclass needs specific validation tests, it can override this method; the subclass is responsible for callingEntry.validate()
or otherwise performing type checks.Nestable
reduces code duplication betweenCollection
andSnapshot
, and encourages more generalized code when working with these types.How Has This Been Tested?
Ran
pytest
from within the repo. Usedlinac_backend
and newlinac_snapshot
fixtures to validate the original trees, a tree with an emptyCollection
, a tree with a cycle, and class instances that fail type checks.Test coverage
Test durations
Where Has This Been Documented?
This PR
Pre-merge checklist
docs/pre-release-notes.sh
and created a pre-release documentation page