-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Allow importing from model data to python. #2581
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
Changes from all commits
3428c1b
f73b99b
edbf03f
b9b75ea
370fa8d
cfb3672
ac958aa
8431e67
372921f
3e410fb
b03267e
f6cea5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ | |
|
|
||
| import pyzstd | ||
|
|
||
| import hugr._hugr as rust | ||
|
|
||
| if TYPE_CHECKING: | ||
| from hugr.hugr.base import Hugr | ||
| from hugr.package import Package | ||
|
|
@@ -112,8 +114,11 @@ def read_envelope(envelope: bytes) -> Package: | |
| case EnvelopeFormat.JSON: | ||
| return ext_s.Package.model_validate_json(payload).deserialize() | ||
| case EnvelopeFormat.MODEL | EnvelopeFormat.MODEL_WITH_EXTS: | ||
| msg = "Decoding HUGR envelopes in MODULE format is not supported yet." | ||
| raise ValueError(msg) | ||
| # TODO Going via JSON is a temporary solution, until we get model import to | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be good to link to an issue here
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added link to #2287 ; will update the description there to clarify that this is the remaining task. |
||
| # python properly implemented. | ||
| # https://github.com/CQCL/hugr/issues/2287 | ||
| json_data = rust.to_json_envelope(envelope) | ||
| return read_envelope(json_data) | ||
|
|
||
|
|
||
| def read_envelope_hugr(envelope: bytes) -> Hugr: | ||
|
|
||
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.
small docstring would help