-
Notifications
You must be signed in to change notification settings - Fork 14
test: Better python roundtrip tests, and lots of fixes #2436
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
Open
aborgna-q
wants to merge
14
commits into
main
Choose a base branch
from
ab/python-roundtrip-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+385
−89
Conversation
This file contains hidden or 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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2436 +/- ##
==========================================
- Coverage 82.56% 82.00% -0.57%
==========================================
Files 247 247
Lines 45892 45925 +33
Branches 41528 41528
==========================================
- Hits 37889 37659 -230
- Misses 5981 6244 +263
Partials 2022 2022
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:
|
33fc29e
to
f56283f
Compare
f56283f
to
49c68c0
Compare
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.
The python validation tests did a roundtrip serialization check by encoding the HUGR, loading it, encoding it again, and checking for differences in the serialization.
This ignored any information loss in the first encoding, and resulted in a lot of hidden bugs.
This PR changes the test in
conftest.py
to instead compare the original HUGR and the loaded one directly, using a "node hash" that computes the main properties of each node and its children in an index-independent way. (we do not traverse graph edges to avoid having a graph isomorphism problem).The node hash is defined as follows, and should be easily extensible if needed. We compare hugrs by checking the hashes of their root modules.
This revealed a bunch of bugs with the json serialization, hugr builders, node iterators, ...:
null
for order edges, but python emitted#ports
instead (and this caused problems when combined with the out port inconsistencies below).Some(TRUE)
it still shows asSome
instead ofSum(tag=1, tys=[[], [Bool]], val=[TRUE])
.Hugr.num_outgoing
andnum_incoming
were counting ports instead of edges...FuncDefn
,Case
, and the likes.The roundtrip checks also have options for checking all the format combinations (one variable for the encoding format and another for converting it with
hugr convert
before loading if necessary).This only does
json-json
for the moment, ashugr-model
detects multiple errors.