From c6f04a4215800a80226ffde8c21600e840df45fc Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Thu, 12 Dec 2024 21:19:41 +0200 Subject: [PATCH 01/11] Add lock file Vulnerability scanning tooling is using the lock file to look for issues. Without this, the tooling will not be able to produce reliable report. --- requirements.txt | 224 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..d7bf8237 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,224 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile pyproject.toml --all-extras --output-file requirements.txt +accessible-pygments==0.0.5 + # via pydata-sphinx-theme +aiohappyeyeballs==2.4.4 + # via aiohttp +aiohttp==3.11.10 + # via black +aiosignal==1.3.1 + # via aiohttp +alabaster==0.7.16 + # via sphinx +annotated-types==0.7.0 + # via pydantic +astroid==3.0.3 + # via pylint +attrs==24.2.0 + # via aiohttp +babel==2.16.0 + # via + # pydata-sphinx-theme + # sphinx +beautifulsoup4==4.12.3 + # via pydata-sphinx-theme +black==23.12.0 + # via qiskit-iqm (pyproject.toml) +cachetools==5.5.0 + # via tox +certifi==2024.8.30 + # via requests +chardet==5.2.0 + # via tox +charset-normalizer==3.4.0 + # via requests +click==8.1.7 + # via black +colorama==0.4.6 + # via tox +coverage==7.6.9 + # via pytest-cov +dill==0.3.9 + # via + # pylint + # qiskit +distlib==0.3.9 + # via virtualenv +docutils==0.20.1 + # via + # pydata-sphinx-theme + # sphinx +filelock==3.16.1 + # via + # tox + # virtualenv +frozenlist==1.5.0 + # via + # aiohttp + # aiosignal +idna==3.10 + # via + # requests + # yarl +imagesize==1.4.1 + # via sphinx +iniconfig==2.0.0 + # via pytest +iqm-client==20.8 + # via qiskit-iqm (pyproject.toml) +isort==5.13.2 + # via + # qiskit-iqm (pyproject.toml) + # pylint +jinja2==3.1.4 + # via sphinx +markupsafe==3.0.2 + # via jinja2 +mccabe==0.7.0 + # via pylint +mockito==1.4.0 + # via qiskit-iqm (pyproject.toml) +mpmath==1.3.0 + # via sympy +multidict==6.1.0 + # via + # aiohttp + # yarl +mypy==1.7.1 + # via qiskit-iqm (pyproject.toml) +mypy-extensions==1.0.0 + # via + # black + # mypy +numpy==2.2.0 + # via + # qiskit-iqm (pyproject.toml) + # iqm-client + # qiskit + # qiskit-aer + # rustworkx + # scipy +packaging==24.2 + # via + # black + # iqm-client + # pyproject-api + # pytest + # sphinx + # tox +pathspec==0.12.1 + # via black +pbr==6.1.0 + # via stevedore +platformdirs==4.3.6 + # via + # black + # pylint + # tox + # virtualenv +pluggy==1.5.0 + # via + # pytest + # tox +propcache==0.2.1 + # via + # aiohttp + # yarl +psutil==6.1.0 + # via qiskit-aer +pydantic==2.10.3 + # via iqm-client +pydantic-core==2.27.1 + # via pydantic +pydata-sphinx-theme==0.16.0 + # via sphinx-book-theme +pygments==2.18.0 + # via + # accessible-pygments + # pydata-sphinx-theme + # sphinx +pylint==3.0.3 + # via + # qiskit-iqm (pyproject.toml) + # pytest-pylint +pyproject-api==1.8.0 + # via tox +pytest==7.4.3 + # via + # qiskit-iqm (pyproject.toml) + # pytest-cov + # pytest-pylint +pytest-cov==4.1.0 + # via qiskit-iqm (pyproject.toml) +pytest-pylint==0.21.0 + # via qiskit-iqm (pyproject.toml) +python-dateutil==2.9.0.post0 + # via qiskit +qiskit==1.1.2 + # via + # qiskit-iqm (pyproject.toml) + # qiskit-aer +qiskit-aer==0.14.2 + # via qiskit-iqm (pyproject.toml) +requests==2.32.3 + # via + # iqm-client + # sphinx +rustworkx==0.15.1 + # via qiskit +scipy==1.14.1 + # via + # qiskit + # qiskit-aer +six==1.17.0 + # via python-dateutil +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.6 + # via beautifulsoup4 +sphinx==7.2.6 + # via + # qiskit-iqm (pyproject.toml) + # pydata-sphinx-theme + # sphinx-book-theme +sphinx-book-theme==1.1.2 + # via qiskit-iqm (pyproject.toml) +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +stevedore==5.4.0 + # via qiskit +symengine==0.13.0 + # via qiskit +sympy==1.13.3 + # via qiskit +tomlkit==0.13.2 + # via pylint +tox==4.11.4 + # via qiskit-iqm (pyproject.toml) +types-jinja2==2.11.9 + # via qiskit-iqm (pyproject.toml) +types-markupsafe==1.1.10 + # via types-jinja2 +typing-extensions==4.12.2 + # via + # mypy + # pydantic + # pydantic-core + # pydata-sphinx-theme + # qiskit +urllib3==2.2.3 + # via requests +virtualenv==20.28.0 + # via tox +yarl==1.18.3 + # via aiohttp From 2c0a257cf8f5b48677ff0eb252d3fd9cee3aaa66 Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Fri, 13 Dec 2024 12:01:22 +0200 Subject: [PATCH 02/11] Add precommit hook Pre commit hook helps the developers execute some tasks before committing. --- .pre-commit-config.yaml | 9 +++++++ pyproject.toml | 4 ++- requirements.txt | 55 ++++++++++++++++++++++++++++++++--------- tox.ini | 11 ++++++++- 4 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..8f62f8fe --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: local + hooks: + - id: pip-compile + name: pip-compile + entry: tox -e pip-compile + language: system + files: ^pyproject\.toml$ + pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index a5129d21..93bdbbe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,9 @@ changelog = "https://github.com/iqm-finland/qiskit-on-iqm/blob/main/CHANGELOG.rs # Add here additional requirements for extra features, to install with: # `pip install qiskit-iqm[dev,docs,testing] dev = [ - "tox == 4.11.4" + "tox == 4.11.4", + "pre_commit == 4.0.1", + "pip-tools == 7.4.1" ] docs = [ "sphinx == 7.2.6", diff --git a/requirements.txt b/requirements.txt index d7bf8237..82481825 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,9 @@ -# This file was autogenerated by uv via the following command: -# uv pip compile pyproject.toml --all-extras --output-file requirements.txt +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile --all-extras --output-file=requirements.txt pyproject.toml +# accessible-pygments==0.0.5 # via pydata-sphinx-theme aiohappyeyeballs==2.4.4 @@ -24,19 +28,25 @@ beautifulsoup4==4.12.3 # via pydata-sphinx-theme black==23.12.0 # via qiskit-iqm (pyproject.toml) +build==1.2.2.post1 + # via pip-tools cachetools==5.5.0 # via tox certifi==2024.8.30 # via requests +cfgv==3.4.0 + # via pre-commit chardet==5.2.0 # via tox charset-normalizer==3.4.0 # via requests click==8.1.7 - # via black + # via + # black + # pip-tools colorama==0.4.6 # via tox -coverage==7.6.9 +coverage[toml]==7.6.9 # via pytest-cov dill==0.3.9 # via @@ -56,6 +66,8 @@ frozenlist==1.5.0 # via # aiohttp # aiosignal +identify==2.6.3 + # via pre-commit idna==3.10 # via # requests @@ -68,8 +80,8 @@ iqm-client==20.8 # via qiskit-iqm (pyproject.toml) isort==5.13.2 # via - # qiskit-iqm (pyproject.toml) # pylint + # qiskit-iqm (pyproject.toml) jinja2==3.1.4 # via sphinx markupsafe==3.0.2 @@ -90,17 +102,20 @@ mypy-extensions==1.0.0 # via # black # mypy +nodeenv==1.9.1 + # via pre-commit numpy==2.2.0 # via - # qiskit-iqm (pyproject.toml) # iqm-client # qiskit # qiskit-aer + # qiskit-iqm (pyproject.toml) # rustworkx # scipy packaging==24.2 # via # black + # build # iqm-client # pyproject-api # pytest @@ -110,6 +125,8 @@ pathspec==0.12.1 # via black pbr==6.1.0 # via stevedore +pip-tools==7.4.1 + # via qiskit-iqm (pyproject.toml) platformdirs==4.3.6 # via # black @@ -120,6 +137,8 @@ pluggy==1.5.0 # via # pytest # tox +pre-commit==4.0.1 + # via qiskit-iqm (pyproject.toml) propcache==0.2.1 # via # aiohttp @@ -139,25 +158,31 @@ pygments==2.18.0 # sphinx pylint==3.0.3 # via - # qiskit-iqm (pyproject.toml) # pytest-pylint + # qiskit-iqm (pyproject.toml) pyproject-api==1.8.0 # via tox +pyproject-hooks==1.2.0 + # via + # build + # pip-tools pytest==7.4.3 # via - # qiskit-iqm (pyproject.toml) # pytest-cov # pytest-pylint + # qiskit-iqm (pyproject.toml) pytest-cov==4.1.0 # via qiskit-iqm (pyproject.toml) pytest-pylint==0.21.0 # via qiskit-iqm (pyproject.toml) python-dateutil==2.9.0.post0 # via qiskit +pyyaml==6.0.2 + # via pre-commit qiskit==1.1.2 # via - # qiskit-iqm (pyproject.toml) # qiskit-aer + # qiskit-iqm (pyproject.toml) qiskit-aer==0.14.2 # via qiskit-iqm (pyproject.toml) requests==2.32.3 @@ -178,8 +203,8 @@ soupsieve==2.6 # via beautifulsoup4 sphinx==7.2.6 # via - # qiskit-iqm (pyproject.toml) # pydata-sphinx-theme + # qiskit-iqm (pyproject.toml) # sphinx-book-theme sphinx-book-theme==1.1.2 # via qiskit-iqm (pyproject.toml) @@ -219,6 +244,14 @@ typing-extensions==4.12.2 urllib3==2.2.3 # via requests virtualenv==20.28.0 - # via tox + # via + # pre-commit + # tox +wheel==0.45.1 + # via pip-tools yarl==1.18.3 # via aiohttp + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools diff --git a/tox.ini b/tox.ini index 22f05630..2fa0688e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 4.11 -envlist = py39, py310, py311, qiskit-{v0.45,v0.46,v1.0,v1.1} +envlist = py39, py310, py311, qiskit-{v0.45,v0.46,v1.0,v1.1}, pip-compile skip_missing_interpreters = True [gh-actions] @@ -87,3 +87,12 @@ deps = build[virtualenv] == 1.0.3 commands = python -m build + +[testenv:pip-compile] +description = + Update the requirements files. +skip_install = True +deps = + pip-tools == 7.4.1 +commands = + pip-compile pyproject.toml --all-extras --output-file=requirements.txt From 546d5d84ec0299a5229173aaface663e394b14f4 Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Fri, 13 Dec 2024 14:26:43 +0200 Subject: [PATCH 03/11] Remove the pip-compile from the standard tox --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 2fa0688e..7117b6f6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 4.11 -envlist = py39, py310, py311, qiskit-{v0.45,v0.46,v1.0,v1.1}, pip-compile +envlist = py39, py310, py311, qiskit-{v0.45,v0.46,v1.0,v1.1} skip_missing_interpreters = True [gh-actions] From 5390e0781886a41662b34274d4ccce7541cb15a5 Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Fri, 13 Dec 2024 14:46:32 +0200 Subject: [PATCH 04/11] Update the contribution documentation --- CONTRIBUTING.rst | 9 ++++++++- tox.ini | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 838cf8b6..ddef24de 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -14,9 +14,10 @@ and install it in editable mode with all the extras: $ git clone git@github.com:iqm-finland/qiskit-on-iqm.git $ cd qiskit-on-iqm $ pip install -e ".[dev,docs,testing]" + $ pre-commit install -To be able to build the docs `graphviz `_ has to be installed. +To be able to build the docs `graphviz `_ has to be installed. Then to build and view the docs run: .. code-block:: bash @@ -30,6 +31,12 @@ Format your code: $ tox -e format +Update the requirements: + +.. code-block:: bash + + $ tox -e pip-compile + Run the tests: .. code-block:: bash diff --git a/tox.ini b/tox.ini index 7117b6f6..2fa0688e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 4.11 -envlist = py39, py310, py311, qiskit-{v0.45,v0.46,v1.0,v1.1} +envlist = py39, py310, py311, qiskit-{v0.45,v0.46,v1.0,v1.1}, pip-compile skip_missing_interpreters = True [gh-actions] From 1541efa5cb9d513a95701949e6adde87f3a78400 Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Fri, 13 Dec 2024 15:03:58 +0200 Subject: [PATCH 05/11] Add ci test for pip-compile --- .github/workflows/ci.yml | 73 +++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1df16f7b..f2e9c8e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,8 @@ jobs: runs-on: ${{ matrix.platform }} strategy: matrix: - platform: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ '3.9', '3.10', '3.11' ] + platform: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v4 - name: Setup Python @@ -29,6 +29,19 @@ jobs: - name: Run tests run: tox + test_requirements_lock: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Regenerate requirements.txt + run: tox -e pip-compile + - name: Check if requirements.txt is up-to-date + run: git diff --exit-code HEAD requirements.txt + test_docs: runs-on: ubuntu-latest steps: @@ -36,7 +49,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: "3.9" - name: Install dependencies run: | python -m pip install --upgrade pip @@ -46,30 +59,30 @@ jobs: run: tox -e docs run_resonance_integration_test: - needs: [test] - if: | - success() && ( - github.event_name == 'schedule' || - (github.event_name == 'push' && github.ref == 'refs/heads/main') - ) - runs-on: ${{ matrix.platform }} - environment: resonance-test # Keep the environment for secure secret management - strategy: - matrix: - platform: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ '3.9', '3.10', '3.11' ] - steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -e ".[dev]" - python -m pip install tox-gh-actions==2.12.0 - - name: Run Resonance example integration test - run: tox -e test_resonance_example - env: - RESONANCE_API_KEY: ${{ secrets.RESONANCE_API_KEY }} + needs: [test] + if: | + success() && ( + github.event_name == 'schedule' || + (github.event_name == 'push' && github.ref == 'refs/heads/main') + ) + runs-on: ${{ matrix.platform }} + environment: resonance-test # Keep the environment for secure secret management + strategy: + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[dev]" + python -m pip install tox-gh-actions==2.12.0 + - name: Run Resonance example integration test + run: tox -e test_resonance_example + env: + RESONANCE_API_KEY: ${{ secrets.RESONANCE_API_KEY }} From e9f4bc25ab05f394926bf7093db52855b9133edf Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Fri, 13 Dec 2024 15:04:59 +0200 Subject: [PATCH 06/11] Fix pip-compile ci job --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2e9c8e3..dbaf6d6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,11 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[dev]" + python -m pip install tox-gh-actions==2.12.0 - name: Regenerate requirements.txt run: tox -e pip-compile - name: Check if requirements.txt is up-to-date From 75fc2ec965e55deb9bc50056e439bdd74d44e8ef Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Mon, 16 Dec 2024 10:37:56 +0200 Subject: [PATCH 07/11] Define python version for pip-compile tox env We are using python 3.11 in github check for requirements lock. Predictable version in the local precommit makes the CI job reliable. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 2fa0688e..f711c7f9 100644 --- a/tox.ini +++ b/tox.ini @@ -92,6 +92,7 @@ commands = description = Update the requirements files. skip_install = True +base_python = python3.11 deps = pip-tools == 7.4.1 commands = From f383478a01bb4915b0006c50d51884303d66bbaa Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Mon, 16 Dec 2024 10:43:32 +0200 Subject: [PATCH 08/11] Add python format as precommit job --- .pre-commit-config.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f62f8fe..318eb383 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,13 @@ repos: + - repo: local + hooks: + - id: format + name: format + entry: tox -e format + language: system + files: \.py$ + pass_filenames: false + - repo: local hooks: - id: pip-compile From bae0a3ed6f78e9bb306ff7c16fb34d58150614f4 Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Mon, 16 Dec 2024 10:47:12 +0200 Subject: [PATCH 09/11] Update changelog --- CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index abab2da0..ce75eddb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,14 @@ Changelog ========= +Version 15.6 +============ + +* Added requirements lock file that is automatically generated with tox and pre-commit. + `#141 `_ +* Added CI test to check that the requirements lock file is up-to-date. + `#141 `_ + Version 15.5 ============ From a54e74d732f705a2e1f33c132caa073f7eece7d6 Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Mon, 16 Dec 2024 13:49:34 +0200 Subject: [PATCH 10/11] Revert "Update changelog" This reverts commit bae0a3ed6f78e9bb306ff7c16fb34d58150614f4. --- CHANGELOG.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ce75eddb..abab2da0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,14 +2,6 @@ Changelog ========= -Version 15.6 -============ - -* Added requirements lock file that is automatically generated with tox and pre-commit. - `#141 `_ -* Added CI test to check that the requirements lock file is up-to-date. - `#141 `_ - Version 15.5 ============ From 8cb84d403639c97ef20647486f58462cefd1bb0b Mon Sep 17 00:00:00 2001 From: Shabeeb Khalid Date: Tue, 17 Dec 2024 11:40:20 +0200 Subject: [PATCH 11/11] Remove lock file checks in CI We cannot guarantee that the lock file remains same in the lifetime. Hence, removing the checks here. --- .github/workflows/ci.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbaf6d6a..fe0fa945 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,24 +29,6 @@ jobs: - name: Run tests run: tox - test_requirements_lock: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -e ".[dev]" - python -m pip install tox-gh-actions==2.12.0 - - name: Regenerate requirements.txt - run: tox -e pip-compile - - name: Check if requirements.txt is up-to-date - run: git diff --exit-code HEAD requirements.txt - test_docs: runs-on: ubuntu-latest steps: