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

feat: Draft for hugr-model with export, import, parsing and pretty printing #1542

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c15b2e1
`hugr-model` import, export and text format draft.
zrho Aug 9, 2024
8f3773f
Import CFGs.
zrho Oct 2, 2024
4e49b90
Made the model import/export test into an insta test.
zrho Oct 2, 2024
b7305fc
Import tail-loop and cond by inferring types from port types.
zrho Oct 2, 2024
2d2a273
Merge branch 'main' into zrho/model-import
zrho Oct 2, 2024
55624b6
Fixed lints.
zrho Oct 2, 2024
2a8c34f
Feature gate the model in `hugr-core`.
zrho Oct 2, 2024
9eb6a6f
Added node and region types.
zrho Oct 2, 2024
deaeea8
Print type hint.
zrho Oct 2, 2024
1cf28df
Add README to hugr-model
zrho Oct 2, 2024
26441df
Lints.
zrho Oct 2, 2024
ecaf640
Added cfgs and tail-loops to tests and fixed bugs.
zrho Oct 2, 2024
6c3703a
Added `cond` node to model import/export test.
zrho Oct 2, 2024
cff376a
Split up the test model files into smaller files.
zrho Oct 2, 2024
df958c9
`load-func` in model import/export test.
zrho Oct 2, 2024
ec1736f
Removed resolved TODOs.
zrho Oct 3, 2024
e82b99c
Feature gate on tests via Cargo.toml
zrho Oct 3, 2024
1d7a9b2
Update hugr-model/Cargo.toml
zrho Oct 3, 2024
9c34183
Update hugr-model/README.md
zrho Oct 3, 2024
3573d44
Update hugr-model/README.md
zrho Oct 3, 2024
ea5f734
Moved dependency features to Cargo.toml's of the individual crates.
zrho Oct 3, 2024
39a835b
Various naming improvements, more explicit define_index! macro.
zrho Oct 3, 2024
280ef39
More doc strings, feature marked as unstable, and some renamed fields.
zrho Oct 3, 2024
e18066d
Update hugr-core/src/import.rs
zrho Oct 4, 2024
8070fd1
Fixed bugs with extension sets, and small improvements.
zrho Oct 4, 2024
14e0e1e
Nits
zrho Oct 4, 2024
706b7ac
Remove println left in from debugging.
zrho Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/change-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ rust: &rust
- "hugr-cli/**"
- "hugr-core/**"
- "hugr-passes/**"
- "hugr-model/**"
- "Cargo.toml"
- "specification/schema/**"
- ".github/workflows/ci-rs.yml"
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ lto = "thin"

[workspace]
resolver = "2"
members = ["hugr", "hugr-core", "hugr-passes", "hugr-cli"]
members = ["hugr", "hugr-core", "hugr-passes", "hugr-cli", "hugr-model"]

[workspace.package]
rust-version = "1.75"
Expand Down Expand Up @@ -62,6 +62,9 @@ clap-verbosity-flag = "2.2.0"
assert_cmd = "2.0.14"
assert_fs = "1.1.1"
predicates = "3.1.0"
indexmap = "2.3.0"
fxhash = "0.2.1"
bumpalo = { version = "3.16.0" }

[profile.dev.package]
insta.opt-level = 3
Expand Down
1 change: 1 addition & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ in
# cargo-llvm-cov is currently marked broken on nixpkgs unstable
pkgs-stable.cargo-llvm-cov
pkgs.graphviz
pkgs.cargo-insta
] ++ lib.optionals
pkgs.stdenv.isDarwin
(with pkgs.darwin.apple_sdk; [
Expand Down
12 changes: 11 additions & 1 deletion hugr-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ workspace = true
[features]
extension_inference = []
declarative = ["serde_yaml"]
model_unstable = ["hugr-model"]

[[test]]
name = "model"
required-features = ["model_unstable"]

[dependencies]
portgraph = { workspace = true, features = ["serde", "petgraph"] }
Expand All @@ -32,7 +37,7 @@ serde = { workspace = true, features = ["derive", "rc"] }
serde_yaml = { workspace = true, optional = true }
typetag = { workspace = true }
smol_str = { workspace = true, features = ["serde"] }
derive_more = { workspace = true, features=["display", "from"]}
derive_more = { workspace = true, features = ["display", "from"] }
itertools = { workspace = true }
html-escape = { workspace = true }
bitvec = { workspace = true, features = ["serde"] }
Expand All @@ -46,6 +51,10 @@ paste = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }
semver = { version = "1.0.23", features = ["serde"] }
hugr-model = { path = "../hugr-model", optional = true }
indexmap.workspace = true
fxhash.workspace = true
bumpalo = { workspace = true, features = ["collections"] }

[dev-dependencies]
rstest = { workspace = true }
Expand All @@ -61,3 +70,4 @@ regex-syntax = { workspace = true }

# Required for documentation examples
hugr = { path = "../hugr" }
serde_yaml = "0.9.34"
3 changes: 3 additions & 0 deletions hugr-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Please read the [API documentation here][].
Not enabled by default.
- `declarative`:
Experimental support for declaring extensions in YAML files, support is limited.
- `model_unstable`
Import and export from the representation defined in the `hugr-model` crate.
Unstable and subject to change. Not enabled by default.

## Recent Changes

Expand Down
2 changes: 1 addition & 1 deletion hugr-core/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pub(crate) mod test {
dataflow_builder.finish_with_outputs(w)
}

pub(super) fn build_main(
pub(crate) fn build_main(
signature: PolyFuncType,
f: impl FnOnce(FunctionBuilder<&mut Hugr>) -> Result<BuildHandle<FuncID<true>>, BuildError>,
) -> Result<Hugr, BuildError> {
Expand Down
Loading
Loading