-
Notifications
You must be signed in to change notification settings - Fork 3
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: Use hugr-cli
for validation
#455
Conversation
d10ba68
to
51a0f4d
Compare
@@ -57,6 +58,7 @@ def main() -> int: | |||
run_int_fn(compiled, 6) | |||
|
|||
|
|||
@pytest.mark.skip(reason="trunc_u has an invalid signature") |
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's going on here?
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 quite sure, I think guppy defined an invalid signature.
It's getting fixed in #454, so I didn't investigate much.
tests/integration/conftest.py
Outdated
guppyval.validate_json(hugr) | ||
except ImportError: | ||
pytest.skip("Skipping validation") | ||
# Install and run the `hugr-cli` validator |
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 comment seems inaccurate - the installation is happening before this file is run
Co-authored-by: Craig Roy <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #455 +/- ##
==========================================
- Coverage 92.70% 90.40% -2.30%
==========================================
Files 49 49
Lines 5525 5525
==========================================
- Hits 5122 4995 -127
- Misses 403 530 +127 ☔ View full report in Codecov by Sentry. |
Many hugr-building tests are showing up as `s` == skipped after #455. We need to `cargo build` the validator first. Also "fix" (perhaps hack) `run_int_fn` to extract the first `module` Hugr from the Package coming back from compilation.
🤖 I have created a release *beep* *boop* --- ## [0.10.0](v0.9.0...v0.10.0) (2024-09-11) ### ⚠ BREAKING CHANGES * Bumped the `hugr` dependency to `0.8.0` * `GuppyModule.load` no longer loads the content of modules but instead just brings the name of the module into scope. Use `GuppyModule.load_all` to get the old behaviour. * Removed `guppylang.hugr_builder.hugr.Hugr`, compiling a module returns a `hugr.Package` instead. ### Features * Add `__version__` field to guppylang ([#473](#473)) ([b996c62](b996c62)) * Add angle type ([#449](#449)) ([12e41e0](12e41e0)) * Add array literals ([#446](#446)) ([a255c02](a255c02)) * Add equality test for booleans ([#394](#394)) ([dd702ce](dd702ce)), closes [#363](#363) * Add pi constant ([#451](#451)) ([9d35a78](9d35a78)) * Add qualified imports and make them the default ([#443](#443)) ([553ec51](553ec51)) * Allow calling of methods ([#440](#440)) ([5a59da3](5a59da3)) * Allow imports of function definitions and aliased imports ([#432](#432)) ([e23b666](e23b666)) * Array indexing ([#415](#415)) ([2199b48](2199b48)), closes [#421](#421) [#422](#422) [#447](#447) * Inout arguments ([#311](#311)) ([060649b](060649b)), closes [#315](#315) [#316](#316) [#349](#349) [#344](#344) [#321](#321) [#331](#331) [#350](#350) [#340](#340) [#351](#351) * range() with single-argument ([#452](#452)) ([d05f369](d05f369)) * Skip checking of redefined functions ([#457](#457)) ([7f9ad32](7f9ad32)) * Support `nat`/`int` ↔ `bool` cast operations ([#459](#459)) ([3b778c3](3b778c3)) * Use `hugr-cli` for validation ([#455](#455)) ([1d0667b](1d0667b)) * Use cell name instead of file for notebook errors ([#382](#382)) ([d542601](d542601)) * Use the hugr builder ([536abf9](536abf9)) ### Bug Fixes * Fix and update demo notebook ([#376](#376)) ([23b2a15](23b2a15)) * Fix linearity checking bug ([#441](#441)) ([0b8ea21](0b8ea21)) * Fix struct definitions in notebooks ([#374](#374)) ([b009465](b009465)) ### Documentation * Update readme, `cargo build` instead of `--extra validation` ([#471](#471)) ([c2a4c86](c2a4c86)) ### Miscellaneous Chores * Update hugr to `0.8.0` ([#454](#454)) ([b02e0d0](b02e0d0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Spinoff of #454
Replaces the validator python library with a small binary that calls out to
hugr-cli validate
.cargo install
lets us download tools likehugr-cli
and use them for local development, but the support for locally scoped tools is quite flaky. By default, tools are installed in a global directory using the latest version available.It can be forced to use a local target directory via an env variable /
cargo
config (which didn't always work while I was testing it), and version selection can only be done by passing explicit arguments to the cmd. As there is no centralCargo.toml
(or similar) config for it, this relies on every usage point always passing exactly the same arguments. Updating the tool version / patching in a git ref ends up being quite error prone.The solution in this PR is inspired by cargo's own
xtask-
subcrates. These are internal crates meant to run some external tool, while centrally defining the dependency versions and artifact paths.The new
validator
bin crate here checks ifhugr-cli
is installed, and callscargo install
with the appropriate parameters otherwise, before running the tool. The version to install matches the one configured inCargo.toml
. This ensures we control the validation in the same way as all the other hugr dependencies (e.g. thehugr
dep used inexecute_llvm
).Running
cargo run
now acts the same as executing a locally-versionedhugr-cli
.drive-by: Created a cargo workspace.
note: I temporarily disabled the tests that required the "collections" extension definition. This will get fixed once we merge #454, I just didn't want to wire in a hacky solution that'll get dropped in the next PR.
Closes #390