Skip to content
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: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
12 changes: 2 additions & 10 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ include:
# global build variables
variables:
IMAGE: rigetti/forest
QVM_URL: "http://qvm:5000"
QUILC_URL: "tcp://quilc:5555"
QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL: "http://qvm:5000"
QCS_SETTINGS_APPLICATIONS_PYQUIL_QUILC_URL: "tcp://quilc:5555"

# Docker images to spin up along with the various CI jobs
services:
Expand All @@ -29,7 +29,6 @@ services:
# for all Python jobs, see rigetti/gitlab-pipelines/python.gitlab-ci.yml
build-docs:
extends: .python
image: python:3.6
script:
- apt-get update && apt-get install -y pandoc
- make docs
Expand All @@ -52,13 +51,6 @@ check-types:
script:
- make check-types

# run the unit tests with Python 3.6
test-py36:
extends: .python
image: python:3.6
script:
- make test

# run the unit tests with Python 3.7, and report coverage
test-py37:
extends: .python
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
Changelog
=========
[v3.0.0](https://github.com/rigetti/pyquil/compare/v3.0.0..master) (In development)
------------------------------------------------------------------------------------

### Announcements

- Python 3.6 is no longer supported. Python 3.7 and 3.8 will continue to be supported.

### Improvements and Changes

- `PyquilConfig` has been replaced by `QCSClientConfiguration`. As a result, the only supported configuration-related
environment variables are:
- `QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL` (replaces `QVM_URL`), and
- `QCS_SETTINGS_APPLICATIONS_PYQUIL_QUILC_URL` (replaces `QUILC_URL`)

- `ForestConnection` and `ForestSession` have been replaced by `api.Client`.

- `QVMCompiler` now produces a `Program` instead of a `PyQuilExecutableResponse`. As a result, `QVM.load()` always
only accepts a `Program`, and `QVM.requires_executable` has been removed.

- `get_benchmarker()` has been removed in favor of calling `BenchmarkConnection` constructor directly.

### Bugfixes

[next](https://github.com/rigetti/pyquil/compare/v2.28.0..master) (In development)
------------------------------------------------------------------------------------

Expand Down
50 changes: 17 additions & 33 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import shutil

import numpy as np
import pytest
from requests import RequestException

from pyquil.api import (
QVMConnection,
QVMCompiler,
ForestConnection,
get_benchmarker,
local_forest_runtime,
Client,
BenchmarkConnection,
)
from pyquil.api._config import PyquilConfig
from pyquil.api._errors import UnknownApiError
from pyquil.api._compiler import QuilcNotRunning, QuilcVersionMismatch
from pyquil.api._abstract_compiler import QuilcNotRunning, QuilcVersionMismatch
from pyquil.api._qvm import QVMNotRunning, QVMVersionMismatch
from pyquil.device import Device
from pyquil.gates import I
from pyquil.paulis import sX
from pyquil.quil import Program
from pyquil.tests.utils import DummyCompiler


@pytest.fixture
Expand Down Expand Up @@ -124,9 +121,9 @@ def test_device(device_raw):


@pytest.fixture(scope="session")
def qvm():
def qvm(client: Client):
try:
qvm = QVMConnection(random_seed=52)
qvm = QVMConnection(client=client, random_seed=52)
qvm.run(Program(I(0)), [])
return qvm
except (RequestException, QVMNotRunning, UnknownApiError) as e:
Expand All @@ -136,10 +133,9 @@ def qvm():


@pytest.fixture()
def compiler(test_device):
def compiler(test_device, client: Client):
try:
config = PyquilConfig()
compiler = QVMCompiler(endpoint=config.quilc_url, device=test_device, timeout=1)
compiler = QVMCompiler(device=test_device, client=client, timeout=1)
compiler.quil_to_native_quil(Program(I(0)))
return compiler
except (RequestException, QuilcNotRunning, UnknownApiError, TimeoutError) as e:
Expand All @@ -148,20 +144,20 @@ def compiler(test_device):
return pytest.skip("This test requires a different version of quilc: {}".format(e))


@pytest.fixture()
def dummy_compiler(test_device: Device, client: Client):
return DummyCompiler(test_device, client)


@pytest.fixture(scope="session")
def forest():
try:
connection = ForestConnection()
connection._wavefunction(Program(I(0)), 52)
return connection
except (RequestException, UnknownApiError) as e:
return pytest.skip("This test requires a Forest connection: {}".format(e))
def client():
return Client()


@pytest.fixture(scope="session")
def benchmarker():
def benchmarker(client: Client):
try:
bm = get_benchmarker(timeout=2)
bm = BenchmarkConnection(client=client, timeout=2)
bm.apply_clifford_to_pauli(Program(I(0)), sX(0))
return bm
except (RequestException, TimeoutError) as e:
Expand All @@ -170,18 +166,6 @@ def benchmarker():
)


@pytest.fixture(scope="session")
def local_qvm_quilc():
"""Execute test with local qvm and quilc running"""
if shutil.which("qvm") is None or shutil.which("quilc") is None:
return pytest.skip(
"This test requires 'qvm' and 'quilc' executables to be installed locally."
)

with local_forest_runtime() as context:
yield context


def _str_to_bool(s):
"""Convert either of the strings 'True' or 'False' to their Boolean equivalent"""
if s == "True":
Expand Down
4 changes: 2 additions & 2 deletions docs/source/apidocs/compilers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ stored on the :py:class:`~pyquil.api.QuantumComputer` object as the ``compiler``
The exact process for compilation depends on whether you're targeting a QPU or a QVM, and
you can conceive of other compilation strategies than those included with pyQuil by default.
Therefore, we define an abstract interface that all compilers must follow. See
:py:class:`~pyquil.api._qac.AbstractCompiler` for more, or use one of the listed compilers below.
:py:class:`~pyquil.api._abstract_compiler.AbstractCompiler` for more, or use one of the listed compilers below.


.. currentmodule:: pyquil.api
.. autosummary::
:toctree: autogen

_qac.AbstractCompiler
_abstract_compiler.AbstractCompiler
QVMCompiler
QPUCompiler
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
no_implicit_reexport = True
allow_redefinition = True

no_implicit_reexport = False

# Ignore errors in all parser-related files
[mypy-pyquil._parser.*]
ignore_errors = True
Expand Down
13 changes: 7 additions & 6 deletions pyquil/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
"""
Module for facilitating connections to the QVM / QPU.
"""

import warnings
from typing import Any

__all__ = [
"QVMConnection",
"QuantumExecutable",
"EncryptedProgram",
"QVMCompiler",
"QPUCompiler",
"Client",
"Device",
"ForestConnection",
"pyquil_protect",
"WavefunctionSimulator",
"QuantumComputer",
Expand All @@ -35,14 +38,12 @@
"QAM",
"QVM",
"QPU",
"QPUConnection",
"BenchmarkConnection",
"get_benchmarker",
]

from pyquil.api._base_connection import ForestConnection
from pyquil.api._benchmark import BenchmarkConnection, get_benchmarker
from pyquil.api._compiler import QVMCompiler, QPUCompiler
from pyquil.api._client import Client
from pyquil.api._benchmark import BenchmarkConnection
from pyquil.api._compiler import QVMCompiler, QPUCompiler, QuantumExecutable, EncryptedProgram
from pyquil.api._error_reporting import pyquil_protect
from pyquil.api._qam import QAM
from pyquil.api._qpu import QPU
Expand Down
Loading