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

Authenticate IBM Quantum account with GH actions to run unit tests #268

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/functional_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
IBM_API_TOKEN: ${{ secrets.IBM_API_TOKEN }}
run: |
python -m pytest -m "not skip"
- name: Install TorchQuantum
Expand Down
3 changes: 1 addition & 2 deletions test/plugin/test_qiskit_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""

import random

import numpy as np
import pytest
from qiskit.quantum_info import Pauli, Statevector
Expand All @@ -40,7 +39,7 @@
}


@pytest.mark.skip
# @pytest.mark.skip
def test_expval_observable():
# seed = 0
# random.seed(seed)
Expand Down
7 changes: 6 additions & 1 deletion torchquantum/plugin/qiskit/qiskit_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
SOFTWARE.
"""

import os
import datetime
import itertools

import numpy as np
import pathos.multiprocessing as multiprocessing
import torch
from qiskit import QuantumCircuit, transpile

from qiskit.exceptions import QiskitError
from qiskit.transpiler import PassManager
from qiskit_aer import AerSimulator
Expand Down Expand Up @@ -64,7 +66,7 @@ def run_job_worker(data):
break
except Exception as e:
if "Job was cancelled" in str(e):
logger.warning(f"Job is cancelled manually.")
logger.warning("Job is cancelled manually.")
return None
else:
logger.warning(f"Job failed because {e}, rerun now.")
Expand Down Expand Up @@ -183,7 +185,10 @@ def qiskit_init(self):

if self.backend is None:
# initialize now
# Retrieve token from environment.
token = os.getenv("IBM_API_TOKEN")
self.provider = get_provider_hub_group_project(
token=token,
hub=self.hub,
group=self.group,
project=self.project,
Expand Down
Loading