Skip to content

Commit

Permalink
Merge pull request #27 from CQCL/release/1.14
Browse files Browse the repository at this point in the history
Release/1.14
  • Loading branch information
cqc-melf authored Apr 27, 2023
2 parents f478f56 + 5105b1f commit d9ed385
Show file tree
Hide file tree
Showing 40 changed files with 1,662 additions and 117 deletions.
34 changes: 12 additions & 22 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,26 @@ jobs:
with:
fetch-depth: '0'
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*
- name: Set up Python 3.8
if: github.event_name == 'push' || github.event_name == 'schedule'
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Build and test (3.8)
if: github.event_name == 'push' || github.event_name == 'schedule'
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Build and test including remote checks (3.9) mypy
python-version: '3.10'
- name: Build and test including remote checks (3.10) mypy
shell: bash
if: (matrix.os == 'macos-12') && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || github.event_name == 'schedule' )
if: (matrix.os == 'macos-12') && (github.event_name == 'push' || (github.event_name == 'pull_request') || github.event_name == 'release' || github.event_name == 'schedule' )
run: |
./.github/workflows/build-test mypy
- name: Build and test including remote checks (3.9) nomypy
if: (matrix.os != 'macos-12') && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || github.event_name == 'schedule')
- name: Build and test including remote checks (3.10) nomypy
if: (matrix.os != 'macos-12') && (github.event_name == 'push' || (github.event_name == 'pull_request') || github.event_name == 'release' || github.event_name == 'schedule')
shell: bash
run: |
./.github/workflows/build-test nomypy
- name: Set up Python 3.10
- name: Set up Python 3.11
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build and test (3.10)
python-version: '3.11'
- name: Build and test (3.11)
if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule'
shell: bash
run: |
Expand Down Expand Up @@ -110,10 +100,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
- name: Download all wheels
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -150,4 +140,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: '3.10'
- name: Upgrade pip and install wheel
run: pip install --upgrade pip wheel
- name: Install pytket aqt
Expand Down
Binary file removed .github/workflows/docs/Quantinuum_logo.png
Binary file not shown.
Binary file added .github/workflows/docs/Quantinuum_logo_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/workflows/docs/Quantinuum_logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 15 additions & 12 deletions .github/workflows/docs/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from pathlib import Path
import shutil
import subprocess
import sys
from typing import Any

DOCS_DIR = Path(sys.argv[0]).absolute().parent
MODULES_DIR = DOCS_DIR.parent.parent.parent
Expand All @@ -16,32 +17,35 @@ PYTKET_AQT_PYPI_LINK = "https://pypi.org/project/pytket-aqt/"
PYTKET_AQT_GITHUB = "https://github.com/CQCL/pytket-aqt"
MODULE = "aqt"

def get_module_version():

def get_module_version() -> Any:
m = import_module(f"pytket.extensions.{MODULE}")
return m._metadata.__extension_version__.split(".")


def remove_dir(dirpath):
def remove_dir(dirpath: Path) -> None:
if dirpath.exists() and dirpath.is_dir():
shutil.rmtree(dirpath)


def fix_links(filepath):
def fix_links(filepath: Path) -> None:
with open(filepath, "r", encoding="utf8") as f:
content = f.read()
content = content.replace("pytket._tket", "pytket")
with open(filepath, "w", encoding="utf8") as f:
f.write(content)


def build_module_docs():
def build_module_docs() -> None:
v = get_module_version()
mod_docs = MODULES_DIR / "docs"
mod_build = mod_docs / "build"
conf_copy = mod_docs / "conf.py"
logo_copy = mod_docs / "Quantinuum_logo.png"
logo_copy_black = mod_docs / "Quantinuum_logo_black.png"
logo_copy_white = mod_docs / "Quantinuum_logo_white.png"
shutil.copy(DOCS_DIR / "conf.py", conf_copy)
shutil.copy(DOCS_DIR / "Quantinuum_logo.png", logo_copy)
shutil.copy(DOCS_DIR / "Quantinuum_logo_black.png", logo_copy_black)
shutil.copy(DOCS_DIR / "Quantinuum_logo_white.png", logo_copy_white)
remove_dir(mod_build)
index_rst = mod_docs / "index.rst"
with open(mod_docs / "intro.txt", "r") as f:
Expand All @@ -51,12 +55,10 @@ def build_module_docs():
)
content.append(f"\tpytket <{PYTKET_DOCS_LINK}>\n")
content.append(f"\tpytket extensions <{PYTKET_EX_DOCS_LINK}>\n")
content.append(
"\n.. toctree::\n\t:caption: Links:\n\t:maxdepth: 1\n\n"
)
content.append("\n.. toctree::\n\t:caption: Links:\n\t:maxdepth: 1\n\n")
content.append(f"\tbug tracker <{PYTKET_AQT_GITHUB}/issues>\n")
content.append(f"\tGitHub <{PYTKET_AQT_GITHUB}>\n")
content.append(f"\tPyPi <{PYTKET_AQT_PYPI_LINK}>\n")
content.append(f"\tPyPi <{PYTKET_AQT_PYPI_LINK}>\n")

with open(index_rst, "w") as f:
f.writelines(content)
Expand All @@ -82,7 +84,8 @@ def build_module_docs():
fix_links(htmlfile)
fix_links(mod_build / "searchindex.js")
conf_copy.unlink()
logo_copy.unlink()
logo_copy_black.unlink()
logo_copy_white.unlink()
index_rst.unlink()


Expand All @@ -102,4 +105,4 @@ if __name__ == "__main__":
MODULES_DIR / "docs" / "build",
dest,
dirs_exist_ok=True,
)
)
45 changes: 33 additions & 12 deletions .github/workflows/docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import re
from typing import Any, Dict, Optional, Tuple
from urllib.parse import urljoin

from docutils import nodes
from docutils.nodes import Element, TextElement
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment

# -*- coding: utf-8 -*-

# Configuration file for the Sphinx documentation builder.
Expand All @@ -10,9 +19,26 @@
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx_copybutton",
]

html_theme = "sphinx_rtd_theme"
pygments_style = "borland"

html_theme = "sphinx_book_theme"

html_theme_options = {
"repository_url": "https://github.com/CQCL/pytket-aqt",
"use_repository_button": True,
"use_issues_button": True,
"logo": {
"image_light": "Quantinuum_logo_black.png",
"image_dark": "Quantinuum_logo_white.png",
},
}

html_static_path = ["_static"]

html_css_files = ["custom.css"]

# -- Extension configuration -------------------------------------------------

Expand All @@ -29,13 +55,6 @@

# The following code is for resolving broken hyperlinks in the doc.

from sphinx.application import Sphinx
from docutils import nodes
from docutils.nodes import Element, TextElement
from sphinx.environment import BuildEnvironment
from urllib.parse import urljoin
import re
from typing import Any, Dict, List, Optional

# Mappings for broken hyperlinks that intersphinx cannot resolve
external_url_mapping = {
Expand Down Expand Up @@ -74,7 +93,8 @@
def add_reference(
app: Sphinx, env: BuildEnvironment, node: Element, contnode: TextElement
) -> Optional[nodes.reference]:
# Fix references in docstrings that are inherited from the base pytket.backends.Backend class.
# Fix references in docstrings that are inherited from the
# base pytket.backends.Backend class.
mapping = app.config.external_url_mapping
if node.astext() in mapping:
newnode = nodes.reference(
Expand All @@ -97,7 +117,7 @@ def correct_signature(
options: Dict,
signature: str,
return_annotation: str,
) -> (str, str):
) -> Tuple[str, str]:

new_signature = signature
new_return_annotation = return_annotation
Expand All @@ -106,7 +126,8 @@ def correct_signature(
new_signature = new_signature.replace(k, v)
if return_annotation is not None:
new_return_annotation = new_return_annotation.replace(k, v)
# e.g. Replace <CXConfigType.Snake: 0> by CXConfigType.Snake to avoid silent failure in later stages.
# e.g. Replace <CXConfigType.Snake: 0> by
# CXConfigType.Snake to avoid silent failure in later stages.
if new_signature is not None:
enums_signature = re.findall(r"<.+?\: \d+>", new_signature)
for e in enums_signature:
Expand All @@ -120,7 +141,7 @@ def correct_signature(
return new_signature, new_return_annotation


def setup(app):
def setup(app: Sphinx) -> None:
app.add_config_value("custom_internal_mapping", {}, "env")
app.add_config_value("external_url_mapping", {}, "env")
app.connect("missing-reference", add_reference)
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/docs/intro.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
pytket-extensions
=================

.. image:: Quantinuum_logo.png
:width: 160px
:align: right


These extensions enable ``pytket` to be used in conjunction with other
platforms. Each extension adds either new methods to the ``pytket`` package to
convert between circuit representations, or new backends to which ``pytket``
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
sphinx ~= 4.3.2
sphinx_rtd_theme
sphinx_book_theme >= 1.0.1, <2.0
sphinx-copybutton
docutils
types-docutils
6 changes: 3 additions & 3 deletions .github/workflows/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Login
uses: atlassian/[email protected].0
uses: atlassian/[email protected].1
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Create Bug
uses: atlassian/[email protected].0
uses: atlassian/[email protected].1
if: contains(github.event.issue.labels.*.name, 'bug')
with:
project: TKET
issuetype: Bug
summary: « [pytket-aqt] ${{ github.event.issue.title }}»
description: ${{ github.event.issue.html_url }}
- name: Create Task
uses: atlassian/[email protected].0
uses: atlassian/[email protected].1
if: "! contains(github.event.issue.labels.*.name, 'bug')"
with:
project: TKET
Expand Down
31 changes: 15 additions & 16 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@ on:

jobs:
lint:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Update pip
run: pip install --upgrade pip
- name: Install black and pylint
run: pip install black~=22.3 pylint~=2.13,!=2.13.6
- name: Check files are formatted with black
run: |
black --check .
- name: Run pylint
run: |
pylint */
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Update pip
run: pip install --upgrade pip
- name: Install black and pylint
run: pip install -r .github/workflows/linting/lint-requirements.txt
- name: Check files are formatted with black
run: |
black --check .
- name: Run pylint
run: |
pylint */
2 changes: 2 additions & 0 deletions .github/workflows/linting/lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black~=22.3
pylint~=2.13,!=2.13.6
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ build
dist
*.pyc
.vscode
.idea
.venv
.mypy_cache
.hypothesis
obj
docs/extensions
.ipynb_checkpoints
pytket/extensions/aqt/_metadata.py
/.python-version
.nox
.pytest_cache
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: local
hooks:
- id: lint
name: lint
entry: nox -rs lint --
language: system
types: [python]
files: "^pytket/.+|^tests/.+|.github/workflows/docs/.+|setup.py|noxfile.py"
require_serial: true
- id: mypy
name: mypy
entry: nox -rs type_check --
language: system
types: [python]
files: "^pytket/.+|^tests/.+|.github/workflows/docs/.+|setup.py|noxfile.py"
require_serial: true
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
exclude: ^docs/
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: detect-private-key
- id: no-commit-to-branch
Loading

0 comments on commit d9ed385

Please sign in to comment.