Skip to content
This repository has been archived by the owner on Mar 6, 2025. It is now read-only.

Commit

Permalink
Add Python 3.12 support (#154)
Browse files Browse the repository at this point in the history
* minimal changes for python 3.12 support

* keep old black python version for now

* Update changelog

* Added python 3.9 deprecation warning

* Update Github Action to test python 3.12 and build docs on python 3.12

* Apply suggestions from code review

Co-authored-by: Vladimir Kukushkin <[email protected]>

* Update pipelines to use python 3.12

* Adjusted error message based on review feedback

* fixed typo

---------

Co-authored-by: Arianne Meijer <[email protected]>
Co-authored-by: Vladimir Kukushkin <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2024
1 parent 80a1634 commit 7d4a090
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ '3.9', '3.10', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]

steps:
- uses: actions/checkout@v4
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
- name: Checkout latest tagged commit
run: |
git checkout $(git describe --tags --abbrev=0)
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
=========

Version 20.9
============

* Added Python 3.12 support `#154 <https://github.com/iqm-finland/iqm-client/pull/154>`_
* Python 3.9 support is deprecated and will be removed in the future

Version 20.8
============

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
]
requires-python = ">=3.9, <3.12"
requires-python = ">=3.9, <3.13"
dependencies = [
"numpy",
"packaging",
Expand Down
5 changes: 5 additions & 0 deletions src/iqm/iqm_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"""Client-side library for connecting to and executing quantum circuits on IQM quantum computers.
"""
from importlib.metadata import PackageNotFoundError, version
import sys
import warnings

from iqm.iqm_client.api import *
from iqm.iqm_client.authentication import *
Expand All @@ -29,3 +31,6 @@
__version__ = "unknown"
finally:
del version, PackageNotFoundError

if sys.version_info < (3, 10):
warnings.warn(DeprecationWarning("Python 3.9 will no longer be supported in a later release of IQM client."))
23 changes: 13 additions & 10 deletions src/iqm/iqm_client/iqm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ def __init__(
username,
password,
)
version_string = 'iqm-client'
self._signature = f'{platform.platform(terse=True)}'
self._signature += f', python {platform.python_version()}'
self._signature += f', iqm-client {version("iqm-client")}'
self._signature += f', iqm-client {version(version_string)}'
if client_signature:
self._signature += f', {client_signature}'
self._architecture: QuantumArchitectureSpecification | None = None
Expand Down Expand Up @@ -648,15 +649,17 @@ def _get_run_v2(self, job_id: UUID, timeout_secs: float = REQUESTS_TIMEOUT) -> R
'metadata': {
'`': calibration_set_id,
'circuits_batch': circuits_batch,
'parameters': None
if result.status_code == 404
else {
'shots': request_parameters['shots'],
'max_circuit_duration_over_t2': request_parameters['max_circuit_duration_over_t2'],
'heralding_mode': request_parameters['heralding_mode'],
'move_validation_mode': request_parameters['move_validation_mode'],
'move_gate_frame_tracking_mode': request_parameters['move_gate_frame_tracking_mode'],
},
'parameters': (
None
if result.status_code == 404
else {
'shots': request_parameters['shots'],
'max_circuit_duration_over_t2': request_parameters['max_circuit_duration_over_t2'],
'heralding_mode': request_parameters['heralding_mode'],
'move_validation_mode': request_parameters['move_validation_mode'],
'move_gate_frame_tracking_mode': request_parameters['move_gate_frame_tracking_mode'],
}
),
'timestamps': {datapoint['stage']: datapoint['timestamp'] for datapoint in timeline},
},
}
Expand Down
8 changes: 4 additions & 4 deletions src/iqm/iqm_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ def name_validator(cls, value):
"""Check if the name of instruction is set to one of the supported quantum operations."""
name = value
if name not in _SUPPORTED_OPERATIONS:
raise ValueError(
f'Unknown operation "{name}". ' f'Supported operations are \"{", ".join(_SUPPORTED_OPERATIONS)}\"'
)
message = ', '.join(_SUPPORTED_OPERATIONS)
raise ValueError(f'Unknown operation "{name}". Supported operations are "{message}"')
return name

@field_validator('implementation')
Expand Down Expand Up @@ -294,9 +293,10 @@ def args_validator(cls, value, info: ValidationInfo):
f'but {tuple(submitted_arg_names)} were given'
)
if not submitted_arg_names <= allowed_arg_names:
message = tuple(allowed_arg_names) if allowed_arg_names else 'no'
raise ValueError(
f'The operation "{name}" allows '
f'{tuple(allowed_arg_names) if allowed_arg_names else "no"} argument(s), '
f'{message} argument(s), '
f'but {tuple(submitted_arg_names)} were given'
)

Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[tox]
minversion = 4.11
envlist = py39, py310, py311
envlist = py39, py310, py311, py312

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[testenv]
package = editable
setenv =
TOXINIDIR = {toxinidir}
VIRTUALENV_PIP = 23.3.1

[testenv:py{39,310,311}]
[testenv:py{39,310,311,312}]
description =
Run automated tests.
extras =
Expand Down

0 comments on commit 7d4a090

Please sign in to comment.