-
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
refactor: Restructure the python code #211
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
640e771
refactor: Move tket2 to a workspace module
aborgna-q 3c03354
Update pyrs name, make it work from the root dir
aborgna-q eee99cb
Update paths in CI
aborgna-q 68b380a
refactor: Move tket2 code to a workspace member
aborgna-q 1630688
Merge branch 'refactor/restructure-core' into refactor/restructure
aborgna-q 0dc1230
refactor: Move tket2 code to a workspace member
aborgna-q 21bc7b3
Merge branch 'refactor/restructure-core' into refactor/restructure
aborgna-q ea84f57
fix missing requirements on py-coverage
aborgna-q 9125156
Configure maturin's Cargo.toml path directly in pyproject
aborgna-q ce95602
Drop unused files
aborgna-q d9a96fc
s/pytket2-tk2/tket2/
aborgna-q 2b7eb39
Ignore poetry lock file
aborgna-q 76bc7c9
Merge remote-tracking branch 'origin/main' into refactor/restructure
aborgna-q e37748f
Add ruff checks to `pre-commit`
aborgna-q 315f085
Drop unrelated `Cargo.toml` changes
aborgna-q 0e8aba8
Drop python version upper limit in poetry config
aborgna-q File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,22 @@ jobs: | |
with: | ||
components: rustfmt, clippy | ||
- uses: mozilla-actions/[email protected] | ||
- name: Check formatting | ||
- name: Check rust formatting | ||
run: cargo fmt -- --check | ||
- name: Check python formatting | ||
uses: chartboost/ruff-action@v1 | ||
with: | ||
args: format --check | ||
- name: Run clippy | ||
run: cargo clippy --all-targets --all-features --workspace -- -D warnings | ||
- name: Build docs | ||
run: cargo doc --no-deps --all-features | ||
env: | ||
RUSTDOCFLAGS: "-Dwarnings" | ||
- name: Python lints | ||
uses: chartboost/ruff-action@v1 | ||
with: | ||
args: check | ||
|
||
benches: | ||
# Not required, we can ignore it for the merge queue check. | ||
|
@@ -101,14 +109,11 @@ jobs: | |
cache: 'pip' | ||
- name: Build pyo3 bindings | ||
run: | | ||
pip install -r requirements.txt | ||
cd pyrs | ||
pip install -r dev-requirements.txt | ||
maturin build | ||
pip install ../target/wheels/*.whl | ||
pip install target/wheels/*.whl | ||
- name: Test pyo3 bindings | ||
run: | | ||
cd pyrs | ||
pytest | ||
run: pytest | ||
|
||
coverage: | ||
if: github.event_name != 'merge_group' | ||
|
@@ -149,15 +154,12 @@ jobs: | |
cache: 'pip' | ||
- name: Build pyo3 bindings | ||
run: | | ||
pip install -r requirements.txt | ||
pip install -r dev-requirements.txt | ||
pip install pytest-cov | ||
cd pyrs | ||
maturin build | ||
pip install ../target/wheels/*.whl | ||
pip install target/wheels/*.whl | ||
- name: Run python tests with coverage instrumentation | ||
run: | | ||
cd pyrs | ||
pytest --cov=./ --cov-report=xml | ||
run: pytest --cov=./ --cov-report=xml | ||
- name: Upload python coverage to codecov.io | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,28 @@ | ||
[package] | ||
name = "tket2" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
bench = false | ||
name = "tket2" | ||
path = "src/lib.rs" | ||
|
||
[profile.release] | ||
lto = "thin" | ||
|
||
[dependencies] | ||
lazy_static = "1.4.0" | ||
cgmath = "0.18.0" | ||
num-rational = "0.4" | ||
num-complex = { version = "0.4", optional = true } | ||
tket-json-rs = { workspace = true } | ||
rayon = "1.5" | ||
thiserror = "1.0.28" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
downcast-rs = "1.2.0" | ||
priority-queue = "1.3.0" | ||
smol_str = "0.2.0" | ||
typetag = "0.2.8" | ||
itertools = { workspace = true } | ||
petgraph = { version = "0.6.3", default-features = false } | ||
serde_yaml = "0.9.22" | ||
# portmatching = { version = "0.2.0", optional = true, features = ["serde"]} | ||
portmatching = { optional = true, git = "https://github.com/lmondada/portmatching", rev = "738c91c", features = [ | ||
"serde", | ||
] } | ||
derive_more = "0.99.17" | ||
quantinuum-hugr = { workspace = true } | ||
portgraph = { workspace = true, features = ["serde"] } | ||
pyo3 = { workspace = true, optional = true, features = ["multiple-pymethods"] } | ||
strum_macros = "0.25.2" | ||
strum = "0.25.0" | ||
fxhash = "0.2.1" | ||
rmp-serde = { version = "1.1.2", optional = true } | ||
delegate = "0.10.0" | ||
csv = { version = "1.2.2" } | ||
chrono = { version = "0.4.30" } | ||
bytemuck = "1.14.0" | ||
stringreader = "0.1.1" | ||
crossbeam-channel = "0.5.8" | ||
tracing = { workspace = true } | ||
|
||
[features] | ||
pyo3 = [ | ||
"dep:pyo3", | ||
"tket-json-rs/pyo3", | ||
"portgraph/pyo3", | ||
"quantinuum-hugr/pyo3", | ||
] | ||
portmatching = ["dep:portmatching", "dep:rmp-serde"] | ||
|
||
[dev-dependencies] | ||
rstest = "0.18.1" | ||
criterion = { version = "0.5.1", features = ["html_reports"] } | ||
webbrowser = "0.8.10" | ||
urlencoding = "2.1.2" | ||
|
||
[[bench]] | ||
name = "bench_main" | ||
harness = false | ||
|
||
[workspace] | ||
resolver = "2" | ||
members = ["tket2", "tket2-py", "compile-rewriter", "taso-optimiser"] | ||
default-members = ["tket2"] | ||
|
||
members = ["pyrs", "compile-rewriter", "taso-optimiser"] | ||
[workspace.package] | ||
version = "0.1.0" | ||
rust-version = "1.70" | ||
edition = "2021" | ||
homepage = "https://github.com/CQCL/tket2" | ||
license-file = "LICENCE" | ||
# authors | ||
|
||
[workspace.dependencies] | ||
|
||
tket2 = { path = "./tket2" } | ||
quantinuum-hugr = { git = "https://github.com/CQCL-DEV/hugr", rev = "0beb165" } | ||
portgraph = { version = "0.10" } | ||
pyo3 = { version = "0.20" } | ||
itertools = { version = "0.11.0" } | ||
tket-json-rs = "0.2.0" | ||
tracing = "0.1.37" | ||
portmatching = { git = "https://github.com/lmondada/portmatching", rev = "738c91c", features = [ | ||
"serde", | ||
] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
[package] | ||
name = "compile-matcher" | ||
version = "0.1.0" | ||
edition = "2021" | ||
edition = { workspace = true } | ||
version = { workspace = true } | ||
rust-version = { workspace = true } | ||
homepage = { workspace = true } | ||
license-file = { workspace = true } | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { version = "4.4.2", features = ["derive"] } | ||
tket2 = { path = "../", features = ["portmatching"] } | ||
tket2 = { workspace = true, features = ["portmatching"] } | ||
quantinuum-hugr = { workspace = true } | ||
itertools = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# Use common dependencies | ||
# Runtime requirements | ||
-r requirements.txt | ||
|
||
# Development requirements | ||
maturin # Build wheels | ||
black # Code formatting | ||
pytest # Unit testing | ||
ruff # Code formatting | ||
pytket # TKET1 | ||
jupyterlab # For running the examples | ||
graphviz # Visualisation of Hugrs in the notebooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule symengine.rs
deleted from
05ae9c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
# List the available commands | ||
help: | ||
@just --list --justfile {{justfile()}} | ||
|
||
# Run all the rust tests | ||
test: | ||
cargo test | ||
cargo test --all-features | ||
|
||
# Auto-fix all clippy warnings | ||
fix: | ||
cargo clippy --fix --allow-staged | ||
cargo clippy --all-targets --all-features --workspace --fix --allow-staged | ||
|
||
# Build the python package wheels | ||
pybuild: | ||
maturin build --release | ||
|
||
# Build the python package for local development | ||
pydevelop: | ||
maturin develop | ||
|
||
# Run the python tests | ||
pytest: pydevelop | ||
pytest | ||
|
||
# Run the pre-commit checks | ||
check: | ||
./.github/pre-commit | ||
|
||
ptest: | ||
(cd pyrs && maturin develop && pytest) | ||
# Format the code | ||
format: | ||
cargo fmt | ||
ruff format . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[tool.poetry] | ||
name = "tket2-py" | ||
version = "0.1.0" | ||
description = "pytket extension for the tket 2 compiler" | ||
classifiers = [] # TODO | ||
authors = [] # TODO | ||
maintainers = [] # TODO | ||
include = ["pyproject.toml"] | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
|
||
packages = [{ include = "tket2-py" }] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10,<3.12" | ||
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. why not 3.12? |
||
|
||
[tool.poetry.dev-dependencies] | ||
maturin = "^1.3.0" | ||
pytket = "*" | ||
pytest = "^7.1.2" | ||
ruff = "^0.1.3" | ||
|
||
[build-system] | ||
requires = ["maturin~=1.3"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "tket2" | ||
version = "0.1.0" | ||
description = "pytket extension for the tket 2 compiler" | ||
authors = [] # TODO | ||
classifiers = [] # TODO | ||
requires-python = ">=3.10" | ||
license = "Apache-2.0" | ||
|
||
[project.urls] | ||
homepage = "https://github.com/CQCL/tket2" | ||
repository = "https://github.com/CQCL/tket2" | ||
|
||
[tool.maturin] | ||
manifest-path = "tket2-py/Cargo.toml" | ||
python-source = "tket2-py" | ||
|
||
[tool.pytest.ini_options] | ||
# Lark throws deprecation warnings for `src_parse` and `src_constants`. | ||
filterwarnings = "ignore::DeprecationWarning:lark.*" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems unrelated?