-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(hugr-py)!: Reexport commonly used classes from the package root #1393
Changes from 4 commits
c5dbf32
812463e
4d0377c
79cbaa3
5da383d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
|
||
from pydantic import ConfigDict, Field | ||
|
||
import hugr | ||
from hugr import get_serialization_version | ||
from hugr.node_port import NodeIdx, PortOffset | ||
|
||
from .ops import OpType | ||
|
@@ -13,8 +11,14 @@ | |
Port = tuple[NodeIdx, PortOffset | None] | ||
Edge = tuple[Port, Port] | ||
|
||
|
||
def serialization_version() -> str: | ||
"""Return the current version of the serialization schema.""" | ||
return "live" | ||
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. Is this really the best we can do? (Sorry - that sounds a bit rude! But I'd hope that it might be, oh, replaced with an actual version number by some part of the release process or something?? That would be fine, but if so I think it'd be good to have a comment here explaining that) 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. I'm not really happy with the unversioned versions, but it's the "no guarantees" value we are currently used. I guess we'll revisit it once |
||
|
||
|
||
VersionField = Field( | ||
default_factory=get_serialization_version, | ||
default_factory=serialization_version, | ||
title="Version", | ||
description="Serialisation Schema Version", | ||
frozen=True, | ||
|
@@ -34,7 +38,9 @@ class SerialHugr(ConfiguredBaseModel): | |
|
||
def to_json(self) -> str: | ||
"""Return a JSON representation of the Hugr.""" | ||
self.encoder = f"hugr-py v{hugr.__version__}" | ||
from hugr import __version__ as hugr_version | ||
|
||
self.encoder = f"hugr-py v{hugr_version}" | ||
return self.model_dump_json() | ||
|
||
@classmethod | ||
|
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.
Is this related? (Neither of these is re-exported)
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.
Not at all :P
It was part of the port of useful things from guppy, but I should probably remove it from here.