Skip to content
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

Include and load serialized std extensions in hugr-py #1450

Closed
aborgna-q opened this issue Aug 21, 2024 · 1 comment · Fixed by #1459 or #1430
Closed

Include and load serialized std extensions in hugr-py #1450

aborgna-q opened this issue Aug 21, 2024 · 1 comment · Fixed by #1459 or #1430
Assignees
Labels
enhancement New feature or request python Pull requests that update Python code

Comments

@aborgna-q
Copy link
Collaborator

aborgna-q commented Aug 21, 2024

Currently we store the rust-defined std extensions as json files in specification/std_extensions/. There can be loaded by the extension model defined in hugr-py's .serialization.extension, but are not included in the wheels.

Instead, we define some operations separately on .std.
We should include the json files in the wheels (compressed with zstd?) and load them when exposing the std extensions from python. We'll still need definitions for operations that require binary-computed signatures (array ops), but we should be able to keep the rest synchronized between python and rust.

@aborgna-q aborgna-q added enhancement New feature or request python Pull requests that update Python code labels Aug 21, 2024
@ss2165
Copy link
Member

ss2165 commented Aug 21, 2024

The extensions should be small enough to avoid compression

@ss2165 ss2165 self-assigned this Aug 21, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 21, 2024
Copies standard extensions to hugr-py source tree, as poetry won't
include anything from outside the tree (not symlinks either).

Existing op/type wrappers now just point to loaded extensions.

Closes #1450
github-merge-queue bot pushed a commit that referenced this issue Aug 30, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.8.0](hugr-py-v0.7.0...hugr-py-v0.8.0)
(2024-08-30)


### ⚠ BREAKING CHANGES

* Moved `itobool`/`ifrombool`/`itostring_{u,s}` to the conversions
extension.
* Binary sums representing fallible values now use tag `1` for the
successful variant
* **hugr-py:** rename `Custom.name` to `Custom.op_name` and
`Func(Defn/Decl).name` to `f_name` to allow for new `name` method
* `ListOp::pop` now returns an option.
* Moved all builder definitions into the `hugr.build` module. Moved
`node_port` and `render` into the `hugr.hugr` module.
* Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` from core
operations to prelude. Rename `ops::leaf` module to `ops::sum`.
* **hugr-py:** `hugr.serialization` module and `to_serial` methods are
now internal only.
* Renamed `_DfBase` to `DfBase` and `_DefinitionBuilder` to
`DefinitionBuilder`
* `idivmod_checked`, `idivmod`, `idiv`, `idiv_checked`, `imod`, `ishl`,
`ishr`, `irotl`, `irotr` operations now only have one width argument for
all inputs and outputs rather than two.
* HUGRs containing opaque operations that don't point to an extension in
the registry will fail to validate. Use `Package` to pack extensions
with HUGRs for serialisation.
* `CustomOp` removed, `OpType` now contains `ExtensionOp` and `OpaqueOp`
directly. `CustomOpError` renamed to`OpaqueOpError`.

### Features

* `Option` / `Result` helpers
([#1481](#1481))
([9698420](9698420))
* Add missing ops ([#1463](#1463))
([841f450](841f450))
* Add more list operations
([#1474](#1474))
([037005f](037005f))
* Bring in the pure-python renderer from guppy
([#1462](#1462))
([001e66a](001e66a))
* disallow opaque ops during validation
([#1431](#1431))
([fbbb805](fbbb805))
* fill out array ops ([#1491](#1491))
([26ec57a](26ec57a))
* **hugr-py:** pretty printing for ops and types
([#1482](#1482))
([aca403a](aca403a))
* **hugr-py:** use serialized extensions in python
([#1459](#1459))
([a61f4df](a61f4df)),
closes [#1450](#1450)
* int operations other than widen/narrow have only one width arg
([#1455](#1455))
([c39ed15](c39ed15))
* Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` to prelude
([#1475](#1475))
([b387505](b387505))
* Move int conversions to `conversions` ext, add to/from usize
([#1490](#1490))
([88913f2](88913f2))


### Bug Fixes

* **hugr-py:** record node children correctly when deserializing
([#1480](#1480))
([331125a](331125a)),
closes [#1479](#1479)
* **py:** Invalid node indexing
([#1457](#1457))
([d6edcd7](d6edcd7))
* schema for array inner types
([#1494](#1494))
([d43cbb2](d43cbb2)),
closes [#1471](#1471)
* Sum value equality. Add unit tests
([#1484](#1484))
([a7b2718](a7b2718))


### Code Refactoring

* flatten `CustomOp` in to `OpType`
([#1429](#1429))
([8e8bba5](8e8bba5))
* **hugr-py:** make serialization (module/methods) private
([#1477](#1477))
([49a5bad](49a5bad))
* Make `_DfBase` and `_DefinitionBuilder` public
([#1461](#1461))
([ea9cca0](ea9cca0))
* Make Either::Right the "success" case
([#1489](#1489))
([8caa572](8caa572))
* Organise the hugr-py modules
([#1460](#1460))
([3ca56f4](3ca56f4))

---
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 <121866228+aborgna-q@users.noreply.github.com>
Co-authored-by: Agustin Borgna <agustin.borgna@quantinuum.com>
github-merge-queue bot pushed a commit that referenced this issue Sep 3, 2024
#1450 embedded the standard extension definitions in hugr-py, including
`collections`, but it didn't add a way to load it as it did with all the
others.

This PR adds a `hugr.std.collections` module that just loads the bundled
json.

drive-by: Implement `__str__` for `FloatVal` and `IntVal`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python Pull requests that update Python code
Projects
None yet
2 participants