-
Notifications
You must be signed in to change notification settings - Fork 6
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!: define wrappers around package that point to internals #1573
Conversation
Closes #1561 So far just top level things, can add inner ones (cfg, blocks, etc.) later. BREAKING CHANGE: `Package` moved to new `hugr.package` module
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1573 +/- ##
==========================================
+ Coverage 85.68% 85.69% +0.01%
==========================================
Files 134 135 +1
Lines 24512 24563 +51
Branches 21512 21512
==========================================
+ Hits 21003 21050 +47
- Misses 2411 2415 +4
Partials 1098 1098
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
hugr-py/src/hugr/package.py
Outdated
def get_package(self) -> Package: | ||
"""Get the package pointed to.""" | ||
return self.package |
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.
What is the purpose of this method?
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.
good point!
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.
(vestigial from original issue which proposed protocols)
def module(self) -> Hugr: | ||
"""Hugr definition of the module.""" | ||
return self.package.modules[self.module_index] |
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.
This could be a property (same for all other methods in this PR)
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.
Nice.
The followup question will now be how do we serialize these :)
hugr-py/src/hugr/package.py
Outdated
"""Create an executable package from a module containing a main function. | ||
|
||
Raises: | ||
StopIteration: If the module does not contain a main function. |
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.
Rethrow a more appropriate exception, with a custom message.
Either a custom one, or ValueError
hugr-py/src/hugr/package.py
Outdated
"""Hugr definition of the module.""" | ||
return self.package.modules[self.module_index] | ||
|
||
def to_executable_package(self) -> "ExecutablePackage": |
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.
from __future__ import annotations
and remove the quotes
🤖 I have created a release *beep* *boop* --- ## [0.9.0](hugr-py-v0.8.1...hugr-py-v0.9.0) (2024-10-14) ### ⚠ BREAKING CHANGES * `Package` moved to new `hugr.package` module * The `length` op in the std `collections` extensions now also returns the list. ### Features * `instantiate` method for `OpDef` ([#1576](#1576)) ([36548ab](36548ab)), closes [#1512](#1512) * define wrappers around package that point to internals ([#1573](#1573)) ([f74dbf3](f74dbf3)) * to/from json for extension/package ([#1575](#1575)) ([f8bf61a](f8bf61a)), closes [#1523](#1523) ### Bug Fixes * Make list length op give back the list ([#1547](#1547)) ([cf31698](cf31698)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: Agustín Borgna <[email protected]>
Closes #1561
So far just top level things, can add inner ones (cfg, blocks, etc.) later.
BREAKING CHANGE:
Package
moved to newhugr.package
module