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

fix(py): Type stubs for calibration types reflect breaking changes in 0.13.0 #421

Merged
merged 52 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8e92065
fix(py): Type stubs for calibration types have been updated to reflec…
MarquessV Nov 13, 2024
1adc016
update mypy
MarquessV Nov 13, 2024
f677d6f
implement workflow for checking changes against pyQuil
MarquessV Nov 13, 2024
83209d6
fix run keyword
MarquessV Nov 13, 2024
4ecdda9
missing |
MarquessV Nov 13, 2024
26a51da
yamlyamlyaml
MarquessV Nov 13, 2024
1c29c66
tweaks to pyquil job
MarquessV Nov 14, 2024
ccf0e20
maybe this is the magic spell?
MarquessV Nov 14, 2024
437ed41
maybe this?
MarquessV Nov 14, 2024
ab5ffe9
install maturin
MarquessV Nov 14, 2024
92b32f9
point maturin to Cargo.toml
MarquessV Nov 14, 2024
238befe
install other deps
MarquessV Nov 14, 2024
92d12c4
give mypy the config
MarquessV Nov 14, 2024
b4c863d
maybe this?
MarquessV Nov 14, 2024
a572f14
use ::warning::
MarquessV Nov 14, 2024
a405549
is this loud enough?
MarquessV Nov 14, 2024
1dec165
maybe this?
MarquessV Nov 14, 2024
d309c3d
simplify
MarquessV Nov 14, 2024
9b0168c
yamldentation
MarquessV Nov 14, 2024
20c952d
cleanup
MarquessV Nov 14, 2024
af36784
run all checks against pyquil, but still fail the job i
MarquessV Nov 14, 2024
3c3946a
separate into different workflow
MarquessV Nov 15, 2024
48ee2fb
remove field
MarquessV Nov 15, 2024
57da577
try this
MarquessV Nov 15, 2024
619bb2b
conclusion?
MarquessV Nov 15, 2024
ca88736
fix yaml
MarquessV Nov 15, 2024
4b42038
missing jobs key
MarquessV Nov 15, 2024
5572ae3
dont want matrix for this job
MarquessV Nov 15, 2024
2e3f507
continue-on-error at workflow level
MarquessV Nov 15, 2024
fe1b039
continue-on-error too high
MarquessV Nov 15, 2024
95fbb28
fix
MarquessV Nov 15, 2024
a74fb68
maybe this?
MarquessV Nov 15, 2024
b383ee9
another try
MarquessV Nov 15, 2024
f42b976
dont need to manually call core
MarquessV Nov 15, 2024
3a6579c
set working directory
MarquessV Nov 15, 2024
db3bf96
improve summary
MarquessV Nov 15, 2024
714688c
simplify and improve logic
MarquessV Nov 15, 2024
de88756
fix log link
MarquessV Nov 15, 2024
c854c5a
add )
MarquessV Nov 15, 2024
242eec9
add async keyword
MarquessV Nov 15, 2024
d24530c
js function syntax
MarquessV Nov 15, 2024
de6b17d
anotha one
MarquessV Nov 15, 2024
33a28dd
anotha one
MarquessV Nov 15, 2024
837ea0b
let
MarquessV Nov 15, 2024
91d2a09
missing backtick
MarquessV Nov 15, 2024
a311e57
init missing vars
MarquessV Nov 15, 2024
8c846c1
simplify log URL construction
MarquessV Nov 18, 2024
d20c800
fix f-string
MarquessV Nov 18, 2024
a97b8b5
fix f-string
MarquessV Nov 18, 2024
2d8cb6a
fix syntax
MarquessV Nov 18, 2024
a3ebfd4
found the braket
MarquessV Nov 21, 2024
cbe1f42
job id not available
MarquessV Nov 21, 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
7 changes: 4 additions & 3 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: davidB/rust-cargo-make@v1
- uses: actions/checkout@v1
- uses: syphar/restore-virtualenv@v1
- name: Run quil-py tests, lints, and formatting checks.
run: cargo make --cwd quil-py
run: |
cargo make --cwd quil-py

fmt:
name: Rustfmt
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/validate-downstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Check pyQuil Compatibility
on:
pull_request:

jobs:
check-pyquil:
name: Check compatibility with pyQuil
runs-on: ubuntu-latest
steps:
- name: Checkout quil-rs Repository
uses: actions/checkout@v4
with:
path: quil-rs

- name: Checkout pyQuil Repository
uses: actions/checkout@v4
with:
repository: "rigetti/pyquil"
path: pyquil

- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Restore Python Virtual Environment
uses: syphar/restore-virtualenv@v1

- name: Setup pyQuil Repository
run: |
pip uninstall -y -r <(pip freeze) || true
pip install "./pyquil[latex]" maturin mypy ruff pytest pytest-mock
maturin develop -m quil-rs/quil-py/Cargo.toml

- name: Run mypy
id: mypy
continue-on-error: true
working-directory: ./pyquil
run: |
mypy pyquil

- name: Run ruff
id: ruff
continue-on-error: true
working-directory: ./pyquil
run: |
ruff check pyquil

- name: Run pytest
id: pytest
continue-on-error: true
working-directory: ./pyquil
run: |
pytest test/unit -x

- name: Post PR Comment and Fail if Necessary
uses: actions/github-script@v6
with:
script: |
const mypyFailed = '${{ steps.mypy.outcome }}' === 'failure';
const ruffFailed = '${{ steps.ruff.outcome }}' === 'failure';
const pytestFailed = '${{ steps.pytest.outcome }}' === 'failure';

const owner = context.repo.owner;
const repo = context.repo.repo;
const issue_number = context.issue.number;

// Fetch existing comment, if it exists
const identifier = `pyQuil-checks-comment`;
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number,
});
const existingComment = comments.data.find(comment => comment.body.startsWith(`<!-- ${identifier} -->`));


async function postOrUpdateComment(body) {
if (existingComment) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body
});
}
}

var body = ""

if (mypyFailed || ruffFailed || pytestFailed) {
body += `⚠️ **pyQuil Compatibility Checks Failed**:\n\n| Tool | Status |\n-----|-----|\n`;

if (mypyFailed) {
body += `| mypy | ❌ Failed |\n`;
}
if (ruffFailed) {
body += `| ruff | ❌ Failed |\n`;
}
if (pytestFailed) {
body += `| pytest | ❌ Failed |\n`;
}
body += `\n**Note**: These failures don't necessarily block the PR but both authors and reviewers should check the results for unintentional breaking changes.`;
} else {
body += `✅ **pyQuil Compatibility Checks Passed**. Great job!`;
}

await postOrUpdateComment(body);
2 changes: 1 addition & 1 deletion quil-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sdist-include = ["README.md"]
dev = [
"ruff>=0.3.7",
"maturin>=1.2.3",
"mypy>=1.1.1",
"mypy>=1.13.0",
"pytest>=7.2.2",
"pdoc>=14.1.0",
"syrupy>=3.0.6"
Expand Down
89 changes: 39 additions & 50 deletions quil-py/quil/instructions/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,13 @@ class UnaryLogic:
def __copy__(self) -> Self:
"""Returns a shallow copy of the class."""

class Calibration:
class CalibrationIdentifier:
def __new__(
cls,
identifier: CalibrationIdentifier,
instructions: Sequence[Instruction],
name: str,
parameters: Sequence[Expression],
qubits: Sequence[Qubit],
modifiers: Sequence[GateModifier],
) -> Self: ...
@property
def name(self) -> str: ...
Expand All @@ -853,14 +855,6 @@ class Calibration:
@qubits.setter
def qubits(self, qubits: Sequence[Qubit]) -> None: ...
@property
def identifier(self) -> CalibrationIdentifier: ...
@identifier.setter
def identifier(self, identifier: CalibrationIdentifier) -> None: ...
@property
def instructions(self) -> List[Instruction]: ...
@instructions.setter
def instructions(self, instructions: Sequence[Instruction]) -> None: ...
@property
def modifiers(self) -> List[GateModifier]: ...
@modifiers.setter
def modifiers(self, modifiers: Sequence[GateModifier]) -> None: ...
Expand All @@ -885,30 +879,31 @@ class Calibration:
def __copy__(self) -> Self:
"""Returns a shallow copy of the class."""

class CalibrationIdentifier:
class Calibration:
def __new__(
cls,
name: str,
parameters: Sequence[Expression],
qubits: Sequence[Qubit],
modifiers: Sequence[GateModifier],
identifier: CalibrationIdentifier,
instructions: Sequence[Instruction],
) -> Self: ...
def name(self) -> str:
"""Get the name that identifies this calibration."""
...
def parameters(self) -> List[Expression]:
"""Get the list of parameters that this calibration will expand into."""
...
def qubits(self) -> List[Qubit]:
"""Get the list of qubits that this calibration will expand into."""
...
def modifiers(self) -> List[GateModifier]:
"""Get the list of parameters that this calibration will expand into."""
@property
def name(self) -> str: ...
@name.setter
def name(self, name: str) -> None: ...
@property
def parameters(self) -> List[Expression]: ...
@parameters.setter
def parameters(self, parameters: Sequence[Expression]) -> None: ...
@property
def qubits(self) -> List[Qubit]: ...
@qubits.setter
def qubits(self, qubits: Sequence[Qubit]) -> None: ...
def identifier(self) -> CalibrationIdentifier: ...
@identifier.setter
def identifier(self, identifier: CalibrationIdentifier) -> None: ...
@property
def modifiers(self) -> List[GateModifier]: ...
@modifiers.setter
def modifiers(self, modifiers: Sequence[GateModifier]) -> None: ...
def instructions(self) -> List[Instruction]: ...
@instructions.setter
def instructions(self, instructions: Sequence[Instruction]) -> None: ...
def to_quil(self) -> str:
"""Attempt to convert the instruction to a valid Quil string.

Expand All @@ -930,11 +925,11 @@ class CalibrationIdentifier:
def __copy__(self) -> Self:
"""Returns a shallow copy of the class."""

class MeasureCalibrationDefinition:
class MeasureCalibrationIdentifier:
def __new__(
cls,
identifier: MeasureCalibrationIdentifier,
instructions: Sequence[Instruction],
qubit: Optional[Qubit],
parameter: str,
) -> Self: ...
@property
def qubit(self) -> Optional[Qubit]: ...
Expand All @@ -944,14 +939,6 @@ class MeasureCalibrationDefinition:
def parameter(self) -> str: ...
@parameter.setter
def parameter(self, parameter: str) -> None: ...
@property
def identifier(self) -> MeasureCalibrationIdentifier: ...
@identifier.setter
def identifier(self, identifier: MeasureCalibrationIdentifier) -> None: ...
@property
def instructions(self) -> List[Instruction]: ...
@instructions.setter
def instructions(self, instructions: Sequence[Instruction]) -> None: ...
def to_quil(self) -> str:
"""Attempt to convert the instruction to a valid Quil string.

Expand All @@ -973,20 +960,22 @@ class MeasureCalibrationDefinition:
def __copy__(self) -> Self:
"""Returns a shallow copy of the class."""

class MeasureCalibrationIdentifier:
class MeasureCalibrationDefinition:
def __new__(
cls,
qubit: Optional[Qubit],
parameter: str,
identifier: MeasureCalibrationIdentifier,
instructions: Sequence[Instruction],
) -> Self: ...
@property
def qubit(self) -> Optional[Qubit]: ...
@qubit.setter
def qubit(self, qubit: Optional[Qubit]) -> None: ...
@property
def parameter(self) -> str: ...
@parameter.setter
def parameter(self, parameter: str) -> None: ...
@property
def identifier(self) -> MeasureCalibrationIdentifier: ...
@identifier.setter
def identifier(self, identifier: MeasureCalibrationIdentifier) -> None: ...
@property
def instructions(self) -> List[Instruction]: ...
@instructions.setter
def instructions(self, instructions: Sequence[Instruction]) -> None: ...
def to_quil(self) -> str:
"""Attempt to convert the instruction to a valid Quil string.

Expand Down
Loading