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(hugr-py): python hugr builder #1098

Merged
merged 57 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0d69ed1
wip(py): hugr builder interface
ss2165 May 15, 2024
144487c
some light stable indices
ss2165 May 16, 2024
09060da
simpler node data
ss2165 May 16, 2024
b3027bf
insert hugr
ss2165 May 16, 2024
60b1cc5
parent tracking in nodedata
ss2165 May 16, 2024
62ffaff
flesh out example
ss2165 May 16, 2024
38c0ba9
add delete_link
ss2165 May 20, 2024
7ebff33
simple identity test
ss2165 May 20, 2024
4c29513
refactor out bimap and add tests
ss2165 May 20, 2024
6469d76
tet annotations
ss2165 May 20, 2024
915a015
[wip] get types from nodes
ss2165 May 20, 2024
fd8cce1
remove "type inference"
ss2165 May 21, 2024
4b5dae0
handle multiports
ss2165 May 21, 2024
76a6700
test `add_op`
ss2165 May 21, 2024
eb738e5
add tuple handling
ss2165 May 21, 2024
6d1f15b
slice based port unpacking
ss2165 May 21, 2024
c29c035
use tmp_path pytest fixture
ss2165 May 21, 2024
a163201
expand tuple test
ss2165 May 21, 2024
5095c15
remove num fields
ss2165 May 21, 2024
560cad7
get insert_nested working
ss2165 May 21, 2024
8edda56
move into standalone test file
ss2165 May 21, 2024
6fb7419
nested dfg building
ss2165 May 22, 2024
784e7ef
validate using stdin
ss2165 May 22, 2024
2c0d7a5
use built binary
ss2165 May 22, 2024
2a6f80f
test stable indices
ss2165 May 22, 2024
a099298
use varargs for wires to save some chars
ss2165 May 22, 2024
944cd0d
dodgy support for commands
ss2165 May 22, 2024
40fc998
ci: cargo build before test
ss2165 May 24, 2024
1e4223f
ci: use built binary in coverage check
ss2165 May 24, 2024
08bd1a5
ci: separate build step
ss2165 May 24, 2024
34cf38e
ci: make test requires
ss2165 May 24, 2024
c1124f4
chmod +x
ss2165 May 24, 2024
9485fef
download binary bin folder
ss2165 May 24, 2024
95d7639
direction enum
ss2165 May 24, 2024
cc6719e
differentiate ports and connected links correctly
ss2165 May 24, 2024
891767b
Squashed commit of the following:
ss2165 May 24, 2024
bcb2669
import Self from typing extensions
ss2165 May 24, 2024
3052c2d
make mypy happy
ss2165 May 24, 2024
df796c7
chmod +x
ss2165 May 24, 2024
53cca4a
fix: bimap existing key overwrite
ss2165 May 28, 2024
9802c58
minor comments
ss2165 May 28, 2024
329f13a
separate sub ports in to internal type
ss2165 May 28, 2024
dd9e351
rename ToPort to Wire
ss2165 May 28, 2024
0d55959
feat: inter graph + state order edge
ss2165 May 28, 2024
5ba5ad9
put `add_dfg` in hugr
ss2165 May 28, 2024
9ebab76
return `Iterator` from `getitem`
ss2165 May 29, 2024
27014ba
remove special tuple methods
ss2165 May 29, 2024
f02a0b8
copy model when serialising
ss2165 May 29, 2024
1862c4e
implement `from_serial`
ss2165 May 29, 2024
14f5933
fixup binary building (feature name changed)
ss2165 May 29, 2024
cecebc1
build cli package
ss2165 May 29, 2024
b8a2642
revert CI to main
ss2165 May 29, 2024
de9d577
[REVERTME] enable CI on PRs in to this branch
ss2165 May 29, 2024
b751e0d
Revert "[REVERTME] enable CI on PRs in to this branch"
ss2165 May 30, 2024
13e54f6
ci: use binary build stage in python CI (#1135)
ss2165 May 29, 2024
13fcde3
feat: put hugr.py behind an underscore
ss2165 May 30, 2024
dc71629
add direction to _Port
ss2165 May 31, 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
69 changes: 65 additions & 4 deletions .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:

env:
SCCACHE_GHA_ENABLED: "true"
HUGR_BIN_DIR: ${{ github.workspace }}/target/debug
HUGR_BIN: ${{ github.workspace }}/target/debug/hugr

jobs:
# Check if changes were made to the relevant files.
Expand Down Expand Up @@ -68,8 +70,59 @@ jobs:
- name: Lint with ruff
run: poetry run ruff check

build_binary:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}

name: Build HUGR binary
runs-on: ubuntu-latest
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build HUGR binary
run: cargo build -p hugr-cli
- name: Upload the binary to the artifacts
uses: actions/upload-artifact@v4
with:
name: hugr_binary
path: target/debug/hugr
test:
needs: [changes, build_binary]
if: ${{ needs.changes.outputs.python == 'true' }}
name: check python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.10', '3.12']
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Install the project libraries
run: poetry install
- name: Download the hugr binary
uses: actions/download-artifact@v4
with:
name: hugr_binary
path: ${{env.HUGR_BIN_DIR}}

- name: Run tests
run: poetry run pytest
run: |
chmod +x $HUGR_BIN
poetry run pytest

# Ensure that the serialization schema is up to date
serialization-schema:
Expand Down Expand Up @@ -106,7 +159,7 @@ jobs:
# even if they are skipped due to no changes in the relevant files.
required-checks:
name: Required checks 🐍
needs: [changes, check, serialization-schema]
needs: [changes, check, test, serialization-schema]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
Expand All @@ -128,7 +181,7 @@ jobs:
echo "All required checks passed"

coverage:
needs: [changes, check]
needs: [changes, test]
# Run only if there are changes in the relevant files and the check job passed or was skipped
if: always() && !failure() && !cancelled() && needs.changes.outputs.python == 'true' && github.event_name != 'merge_group'
runs-on: ubuntu-latest
Expand All @@ -146,9 +199,17 @@ jobs:

- name: Install the project libraries
run: poetry install
- name: Download the hugr binary
uses: actions/download-artifact@v4
with:
name: hugr_binary
path: ${{env.HUGR_BIN_DIR}}


- name: Run python tests with coverage instrumentation
run: poetry run pytest --cov=./ --cov-report=xml
run: |
chmod +x $HUGR_BIN
poetry run pytest --cov=./ --cov-report=xml

- name: Upload python coverage to codecov.io
uses: codecov/codecov-action@v4
Expand Down
Loading
Loading