-
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(tket2-hseries): cli extension dumping #584
Changes from 18 commits
e997eca
c14792b
7bc2fb5
988f5d5
bf1462a
931bacf
1cf7ed8
3da95ff
5729d2b
7141d51
6a3d951
57f5465
948273b
a68bde5
c784e17
8bed3a3
bdc164c
ef9f076
e600f68
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 |
---|---|---|
|
@@ -278,11 +278,34 @@ jobs: | |
flags: python | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
# Ensure that serialized extensions match rust implementation | ||
tket2-extensions: | ||
needs: [changes, tests-rs-stable-all-features] | ||
if: ${{ needs.changes.outputs.rust == 'true' && github.event_name != 'merge_group' }} | ||
name: Check standard extensions | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: mozilla-actions/[email protected] | ||
- name: Install stable toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- uses: extractions/setup-just@v2 | ||
- name: Generate the updated definitions | ||
run: just gen-extensions | ||
- name: Check if the declarations are up to date | ||
run: | | ||
git diff --exit-code --name-only tket2-py/tket2/extensions/_json_defs | ||
if [ $? -ne 0 ]; then | ||
echo "The serialized standard extensions are not up to date" | ||
echo "Please run 'just gen-extensions' and commit the changes" | ||
exit 1 | ||
fi | ||
|
||
# This is a meta job to mark successful completion of the required checks, | ||
# even if they are skipped due to no changes in the relevant files. | ||
required-checks: | ||
name: Required checks 🦀+🐍 | ||
needs: [changes, check-rs, check-py, tests-rs-stable-no-features, tests-rs-stable-all-features, tests-py] | ||
needs: [changes, check-rs, check-py, tests-rs-stable-no-features, tests-rs-stable-all-features, tests-py, tket2-extensions] | ||
if: ${{ !cancelled() }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,14 @@ description = "TKET2 tool for preparing and validating `Hugr`s for compilation t | |
keywords = ["Quantum", "Quantinuum"] | ||
categories = ["compilers"] | ||
|
||
[features] | ||
default = ["cli"] | ||
cli = ["dep:clap", "dep:hugr-cli", "dep:clap-verbosity-flag", "dep:clio"] | ||
|
||
[[bin]] | ||
name = "tket2-hseries" | ||
required-features = ["cli"] | ||
|
||
[dependencies] | ||
hugr.workspace = true | ||
tket2 = { path = "../tket2", version = "0.2.0" } | ||
|
@@ -24,6 +32,10 @@ strum.workspace = true | |
strum_macros.workspace = true | ||
thiserror.workspace = true | ||
itertools.workspace = true | ||
clap = { workspace = true, optional = true} | ||
hugr-cli = { version = "*", optional = true } | ||
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 think these versions need to be fixed |
||
clap-verbosity-flag = { version = "*", optional = true } | ||
clio = { version = "*", features = ["clap-parse"], optional = true } | ||
|
||
[dev-dependencies] | ||
cool_asserts.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! CLI for tket2-hseries | ||
|
||
use clap::Parser as _; | ||
use hugr::extension::ExtensionRegistry; | ||
use tket2_hseries::cli::CliArgs; | ||
|
||
fn main() { | ||
match CliArgs::parse() { | ||
CliArgs::GenExtensions(args) => { | ||
let reg = ExtensionRegistry::try_new([ | ||
tket2::extension::TKET2_EXTENSION.to_owned(), | ||
tket2::extension::angle::ANGLE_EXTENSION.to_owned(), | ||
tket2_hseries::extension::hseries::EXTENSION.to_owned(), | ||
tket2_hseries::extension::futures::EXTENSION.to_owned(), | ||
tket2_hseries::extension::result::EXTENSION.to_owned(), | ||
]) | ||
.unwrap(); | ||
|
||
args.run_dump(®); | ||
} | ||
_ => { | ||
eprintln!("Unknown command"); | ||
std::process::exit(1); | ||
} | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//! CLI tools for tket2-hseries. | ||
|
||
use clap::Parser; | ||
|
||
/// CLI arguments. | ||
#[derive(Parser, Debug)] | ||
#[clap(version = "1.0", long_about = None)] | ||
#[clap(about = "HUGR CLI tools.")] | ||
#[group(id = "hugr")] | ||
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 right? also I don't think version is right? 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. fixed |
||
#[non_exhaustive] | ||
pub enum CliArgs { | ||
/// Generate serialized extensions. | ||
GenExtensions(hugr_cli::extensions::ExtArgs), | ||
} |
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.
To extend the hugr cli this should be called something prefixed with
hugr-
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.
I'm not sure this naturally extends the hugr cli, I think its fine stand alone for now. It's main use is within the repo anyway (using the justfile)