Skip to content

Commit

Permalink
Merge branch 'develop' into feature/py311
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Oct 3, 2023
2 parents 1645516 + d3ee82e commit 3647bd6
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
os: ['ubuntu-22.04', 'macos-12', 'windows-2022']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
needs: publish_to_pypi
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Python 3.10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: build docs
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ circuit.H(0)
circuit.CX(0, 1)
circuit.CX(0, 2)
circuit.measure_all()
circuit = backend.get_compiled_circuit(circuit)
compiled_circuit = backend.get_compiled_circuit(circuit)

result = backend.run_circuit(c, n_shots=100)
result = backend.run_circuit(compiled_circuit, n_shots=100)
print(result.get_shots())
```

Expand Down
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
~~~~~~~~~

Unreleased
----------

* Update pytket version requirement to 1.20.
* Update iqm-client version requirement to 14.0.
* Fix job status checks.

0.6.0 (March 2023)
------------------

Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace_packages = True
check_untyped_defs = True

warn_redundant_casts = True
warn_unused_ignores = False
warn_unused_ignores = True
warn_no_return = False
warn_return_any = True
warn_unreachable = True
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/iqm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"""

# _metadata.py is copied to the folder after installation.
from ._metadata import __extension_version__, __extension_name__ # type: ignore
from ._metadata import __extension_version__, __extension_name__
from .backends import IQMBackend
from .backends.config import IQMConfig, set_iqm_config
6 changes: 3 additions & 3 deletions pytket/extensions/iqm/backends/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def set_iqm_config(
"""Set default value for IQM API token."""
config = IQMConfig.from_default_config_file()
if auth_server_url is not None:
config.auth_server_url = auth_server_url
config.auth_server_url = auth_server_url # type: ignore
if username is not None:
config.username = username
config.username = username # type: ignore
if password is not None:
config.password = password
config.password = password # type: ignore
config.update_default_config_file()
30 changes: 13 additions & 17 deletions pytket/extensions/iqm/backends/iqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,18 @@
import json
from typing import cast, Dict, List, Optional, Sequence, Tuple, Union
from uuid import UUID
from iqm_client.iqm_client import Circuit as IQMCircuit
from iqm_client.iqm_client import (
Instruction,
IQMClient,
Metadata,
)
from iqm.iqm_client.iqm_client import Circuit as IQMCircuit
from iqm.iqm_client.iqm_client import Instruction, IQMClient, Metadata, Status
import numpy as np
from pytket.backends import Backend, CircuitStatus, ResultHandle, StatusEnum
from pytket.backends.backend import KwargTypes
from pytket.backends.backend_exceptions import CircuitNotRunError
from pytket.backends.backendinfo import BackendInfo
from pytket.backends.backendresult import BackendResult
from pytket.backends.resulthandle import _ResultIdTuple
from pytket.circuit import Circuit, Node, OpType # type: ignore
from pytket.circuit import Circuit, Node, OpType
from pytket.extensions.iqm._metadata import __extension_version__
from pytket.passes import ( # type: ignore
from pytket.passes import (
BasePass,
SequencePass,
SynthesiseTket,
Expand All @@ -43,7 +39,7 @@
DelayMeasures,
SimplifyInitial,
)
from pytket.predicates import ( # type: ignore
from pytket.predicates import (
ConnectivityPredicate,
GateSetPredicate,
NoClassicalControlPredicate,
Expand All @@ -53,7 +49,7 @@
NoSymbolsPredicate,
Predicate,
)
from pytket.architecture import Architecture # type: ignore
from pytket.architecture import Architecture
from pytket.utils import prepare_circuit
from pytket.utils.outcomearray import OutcomeArray
from .config import IQMConfig
Expand Down Expand Up @@ -111,13 +107,13 @@ def __init__(
config = IQMConfig.from_default_config_file()

if auth_server_url is None:
auth_server_url = config.auth_server_url
auth_server_url = config.auth_server_url # type: ignore
if username is None:
username = config.username
username = config.username # type: ignore
if username is None:
raise IqmAuthenticationError()
if password is None:
password = config.password
password = config.password # type: ignore
if password is None:
raise IqmAuthenticationError()

Expand Down Expand Up @@ -220,7 +216,7 @@ def process_circuits(
else:
c0, ppcirc_rep = c, None
instrs = _translate_iqm(c0)
qm = {str(qb): _as_name(qb) for qb in c.qubits}
qm = {str(qb): _as_name(cast(Node, qb)) for qb in c.qubits}
iqmc = IQMCircuit(
name=c.name if c.name else f"circuit_{i}",
instructions=instrs,
Expand All @@ -247,9 +243,9 @@ def circuit_status(self, handle: ResultHandle) -> CircuitStatus:
run_id = UUID(bytes=cast(bytes, handle[0]))
run_result = self._client.get_run(run_id)
status = run_result.status
if status == "pending":
if status == Status.PENDING_EXECUTION:
return CircuitStatus(StatusEnum.SUBMITTED)
elif status == "ready":
elif status == Status.READY:
measurements = cast(dict, run_result.measurements)[0]
shots = OutcomeArray.from_readouts(
np.array(
Expand All @@ -266,7 +262,7 @@ def circuit_status(self, handle: ResultHandle) -> CircuitStatus:
)
return CircuitStatus(StatusEnum.COMPLETED)
else:
assert status == "failed"
assert status == Status.FAILED
return CircuitStatus(StatusEnum.ERROR, cast(str, run_result.message))

def get_result(self, handle: ResultHandle, **kwargs: KwargTypes) -> BackendResult:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
license="Apache 2",
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=["pytket ~= 1.13", "iqm-client ~= 11.8"],
install_requires=["pytket ~= 1.20", "iqm-client ~= 14.0"],
classifiers=[
"Environment :: Console",
"Programming Language :: Python :: 3.9",
Expand Down
4 changes: 2 additions & 2 deletions tests/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import pytest
from requests import get
from conftest import get_demo_url # type: ignore
from iqm_client.iqm_client import ClientAuthenticationError, Metadata, RunRequest
from pytket.circuit import Circuit # type: ignore
from iqm.iqm_client.iqm_client import ClientAuthenticationError, Metadata, RunRequest
from pytket.circuit import Circuit
from pytket.backends import StatusEnum
from pytket.extensions.iqm import IQMBackend

Expand Down
2 changes: 1 addition & 1 deletion tests/convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import os
import numpy as np
from pytket.circuit import Circuit, OpType # type: ignore
from pytket.circuit import Circuit, OpType
from pytket.extensions.iqm.backends.iqm import _iqm_rebase

skip_remote_tests: bool = os.getenv("PYTKET_RUN_REMOTE_TESTS") is None
Expand Down

0 comments on commit 3647bd6

Please sign in to comment.