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

[WIP] Issue-181 | Prepare for summer school release #182

Merged
merged 11 commits into from
Jun 27, 2022
49 changes: 49 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

name: Deploy Docs

on:
workflow_dispatch:

jobs:
docs_publish:
if: ${{ startsWith(github.ref, 'refs/heads/stable') && contains('["manoelmarques","mtreinish","dsvandet","awcross1","quantumjim","grace-harper-ibm","IceKhan13"]', github.actor) }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: ./.github/actions/install-machine-learning
- name: Install Dependencies
run: |
pip install jupyter sphinx_rtd_theme qiskit-terra[visualization] 'torchvision<0.10.0'
sudo apt-get install -y pandoc graphviz
shell: bash
- name: Build and publish
env:
encrypted_rclone_key: ${{ secrets.encrypted_rclone_key }}
encrypted_rclone_iv: ${{ secrets.encrypted_rclone_iv }}
QISKIT_PARALLEL: False
QISKIT_DOCS_BUILD_TUTORIALS: 'always'
run: |
echo "earliest_version: 0.1.0" >> releasenotes/config.yaml
tools/ignore_untagged_notes.sh
make html
tools/deploy_documentation.sh
shell: bash
39 changes: 39 additions & 0 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

name: Release to PyPi

on:
push:
tags:
- '*'

jobs:
code_publish:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Deploy to Pypi
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: qiskit
run : |
pip install -U twine pip setuptools virtualenv wheel
python3 setup.py sdist bdist_wheel

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is a c++ extension in the package this won't be portable and isn't something you should publish as it will depend on the system libraries versions. You should leverage cibuildwheel here to build portable wheels of the package for distribution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtreinish How do we test different distros for aer for example?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't really have to test with different distros in CI, that's what cibuildwheel is for. It builds the binaries in the manylinux docker image to ensure the glibc and other libraries are at old enough versions (by basically just using red hat which is always the oldest) and then auditwheel is used to statically link any dynamic libs and check the symbols are compatible with the manylinux packaging specs and update the wheel tags. If you configure cibiuldwheel correctly and have it run tests of the wheels it should be sufficient to have confidence it will work in any environment that is compatible with the manylinux tags

twine upload dist/qiskit*
shell: bash
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
# TODO: swap this with always if tutorial execution is too slow for ci and needs
# a separate job
# nbsphinx_execute = os.getenv('QISKIT_DOCS_BUILD_TUTORIALS', 'never')
nbsphinx_execute = "always"
nbsphinx_execute = "never"
nbsphinx_widgets_path = ""
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
192 changes: 192 additions & 0 deletions docs/how_tos/1-how-to-query-code-database.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "afc9dead",
"metadata": {},
"source": [
"# How-to: query codes database"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0aca94a",
"metadata": {},
"outputs": [],
"source": [
"from qiskit_qec.qec_codebase.qec_codebase_interactor import QECCodeBase\n",
"from qiskit_qec.operators.pauli_list import PauliList\n",
"from qiskit_qec.structures.gauge import GaugeGroup\n",
"from qiskit_qec.codes import SubSystemCode\n",
"from qiskit_qec.exceptions import QiskitQECError"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29d05317",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"codebase_dir_path = os.environ.get(\"CODE_DB_PATH\")\n",
"db = QECCodeBase(codebase_dir_path)"
]
},
{
"cell_type": "markdown",
"id": "6f7ec06d",
"metadata": {},
"source": [
"### Basic query"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "caf152da",
"metadata": {},
"outputs": [],
"source": [
"derulo_codes = db.get_subsystem_code(2, 1) # all 2,1 codes\n",
"print(\"derulo\", len(derulo_codes))\n",
"print(derulo_codes[0].gauge_group.generators)\n",
"print(derulo_codes[0].parameters)"
]
},
{
"cell_type": "markdown",
"id": "647b9829",
"metadata": {},
"source": [
"### Multi query"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a7a3e592",
"metadata": {},
"outputs": [],
"source": [
"swift_codes = db.get_subsystem_code([3, 2], [0, 1]) # all codes: (2,0), (2,1), (3,0), (3,1)\n",
"len(swift_codes)"
]
},
{
"cell_type": "markdown",
"id": "326981dc",
"metadata": {},
"source": [
"### QUERY sans results\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ffaa7d2e",
"metadata": {},
"outputs": [],
"source": [
"nope_codes = db.get_subsystem_code(3, 4)\n",
"print(\"nope\", len(nope_codes))"
]
},
{
"cell_type": "markdown",
"id": "92252b55",
"metadata": {},
"source": [
"### Query with parameters\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dee58738",
"metadata": {},
"outputs": [],
"source": [
"the1975_additional_params = {\"logical_ops\": \"ixi\"}\n",
"the1975_codes = db.get_subsystem_code(\n",
" 3, 2, **the1975_additional_params\n",
") # all (3,2) codes that have css_logicals === \"ixi\"\n",
"print(\"1975\", len(the1975_codes))\n",
"\n",
"glass_animals_params = {\"weight_enumerator\": 1}\n",
"glass_animals_codes = db.get_subsystem_code(\n",
" 2, 1, acceptable_missing_params={\"weight_enumerator\"}, **glass_animals_params\n",
") # all codes (2,1) such that they either have \"1\" in their weight_enumerator list OR don't have weight_enumerator as a variable\n",
"print(\"glass\", len(glass_animals_codes))"
]
},
{
"cell_type": "markdown",
"id": "fc4287da",
"metadata": {},
"source": [
"### Deriving your own code"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f70d6ddc",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"new_code = derulo_codes[0]\n",
"new_code.parameters[\"my_new_param\"] = 123\n",
"print(new_code.parameters)\n",
"\n",
"db.store_new_subsystem_code(new_code, allow_new_fields=True)\n",
"new_derulo_codes = db.get_subsystem_code(2, 1) # all 2,1 codes\n",
"print(\"new_derulo_codes\", len(new_derulo_codes))\n",
"\n",
"# You can limit your query results to only those in the standard codebase (Andrew's codebase)\n",
"# by telling the database not to query the playground codebase\n",
"\n",
"only_standard_codes_derulo = db.get_subsystem_code(2, 1, allow_playground=False)\n",
"print(\"only standard derulo codes\", len(only_standard_codes_derulo))\n",
"\n",
"# If you're going to add a lot of codes at once, set cache=True and flush after:\n",
"my_code = SubSystemCode(GaugeGroup(PauliList(\"XX\")))\n",
"my_code.parameters = {db.IS_GF4LINEAR: 1, db.N: 4, db.K: 2}\n",
"\n",
"for i in range(300):\n",
" db.store_new_subsystem_code(my_code, flush_cache=False, force=True)\n",
"\n",
"db.flush_cache() # actually create/write to the json file\n",
"\n",
"retrieved_codes = db.get_subsystem_code(4, 2)\n",
"\n",
"db.delete_playground_codebase(True) # kill all the codes you've made"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading