Skip to content

Commit

Permalink
automated push from d6f3095527106c0b51a6ee0e44ff915ccf29363c
Browse files Browse the repository at this point in the history
  • Loading branch information
qcware-cibot committed Mar 15, 2022
1 parent 4434714 commit 5d3cb70
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 35 deletions.
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "qcware"
version = "7.4.0"
version = "7.4.1"
description = "The python client for QC Ware's Forge SaaS quantum computing product"
authors = ["Vic Putz <vic.putz@qcware.com>","Bryan Burr <bryan.e.burr@qcware.com"]
packages = [
Expand All @@ -22,14 +22,14 @@ classifiers = [


[tool.poetry.dependencies]
python = "^3.9"
python = ">=3.7,<3.11"
aiohttp = ">= 3.7.4.post0"
backoff = ">= 1.10.0"
colorama = ">= 0.4.4"
icontract = ">= 2.5.3"
lz4 = ">= 3.1.3"
networkx = ">= 2.5.1"
numpy = ">= 1.21.0"
numpy = "^1.21.5"
packaging = ">= 20.9"
pydantic = ">= 1.8.2"
python-decouple = ">= 3.4"
Expand All @@ -38,3 +38,8 @@ qubovert = ">= 1.2.3"
requests = ">= 2.25.1"
tabulate = ">= 0.8.9"
setuptools = ">= 57.1.0"
toolz = ">=0.11.2"

[tool.poetry.dev-dependencies]
tox = "^3.24.5"
pytest = "^7.1.0"
2 changes: 1 addition & 1 deletion qcware/forge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
try:
__version__ = pkg_resources.get_distribution("qcware").version
except Exception:
__version__ = "7.4.0"
__version__ = "7.4.1"

import logging

Expand Down
30 changes: 15 additions & 15 deletions qcware/forge/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from contextlib import contextmanager
from enum import Enum
from functools import reduce
from typing import Annotated, Optional
from typing import Optional
from urllib.parse import urljoin, urlparse

import colorama # type: ignore
Expand Down Expand Up @@ -415,10 +415,10 @@ def set_ibmq_credentials_from_ibmq_provider(

class IBMQCredentials(BaseModel):

token: Optional[Annotated[str, Field(max_length=255)]]
hub: Optional[Annotated[str, Field(max_length=255)]]
group: Optional[Annotated[str, Field(max_length=255)]]
project: Optional[Annotated[str, Field(max_length=255)]]
token: Optional[str]
hub: Optional[str]
group: Optional[str]
project: Optional[str]

@classmethod
def from_ibmq(cls, ibmq):
Expand All @@ -441,7 +441,7 @@ class Config:


class ApiCredentials(BaseModel):
qcware_api_key: Optional[Annotated[str, Field(max_length=255)]] = None
qcware_api_key: Optional[str] = None
ibmq: Optional[IBMQCredentials] = None

class Config:
Expand All @@ -468,11 +468,11 @@ class Environment(BaseModel):
This is set via the environment variable QCWARE_ENVIRONMENT_SOURCE_FILE.
"""

client: Annotated[str, Field(max_length=255)]
client_version: Annotated[str, Field(max_length=255)]
python_version: Annotated[str, Field(max_length=255)]
environment: Annotated[str, Field(max_length=255)]
source_file: Annotated[str, Field(max_length=255)]
client: str
client_version: str
python_version: str
environment: str
source_file: str


def set_environment_environment(new_environment: str):
Expand All @@ -494,12 +494,12 @@ class ApiCallContext(BaseModel):
override only one field (or a subset).
"""

qcware_host: Optional[Annotated[str, Field(max_length=255)]] = None
qcware_host: Optional[str] = None
credentials: Optional[ApiCredentials] = None
environment: Optional[Environment] = None
server_timeout: Optional[Annotated[int, Field(ge=0)]] = None
client_timeout: Optional[Annotated[int, Field(ge=0)]] = None
async_interval_between_tries: Optional[Annotated[float, Field(ge=0)]] = None
server_timeout: Optional[int] = None
client_timeout: Optional[int] = None
async_interval_between_tries: Optional[float] = None
scheduling_mode: Optional[SchedulingMode] = None

class Config:
Expand Down
10 changes: 5 additions & 5 deletions qcware/forge/qml/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import Optional
from typing import Optional, Tuple

from qcware.forge.qml import fit, predict

Expand All @@ -20,7 +20,7 @@ def __init__(
backend: str = "qcware/cpu_simulator",
num_measurements: int = 100,
absolute: bool = False,
opt_shape: Optional[tuple[int, int]] = None,
opt_shape: Optional[Tuple[int, int]] = None,
):
self.parameters = dict(
loader_mode=loader_mode,
Expand All @@ -40,7 +40,7 @@ def __init__(
backend: str = "qcware/cpu_simulator",
num_measurements: int = 100,
absolute: bool = False,
opt_shape: Optional[tuple[int, int]] = None,
opt_shape: Optional[Tuple[int, int]] = None,
):
self.parameters = dict(
n_neighbors=n_neighbors,
Expand All @@ -60,7 +60,7 @@ def __init__(
backend: str = "qcware/cpu_simulator",
num_measurements: int = 100,
absolute: bool = False,
opt_shape: Optional[tuple[int, int]] = None,
opt_shape: Optional[Tuple[int, int]] = None,
):
self.parameters = dict(
n_neighbors=n_neighbors,
Expand All @@ -85,7 +85,7 @@ def __init__(
backend: str = "qcware/cpu_simulator",
num_measurements: int = 100,
absolute: bool = False,
opt_shape: Optional[tuple[int, int]] = None,
opt_shape: Optional[Tuple[int, int]] = None,
):
self.parameters = dict(
n_clusters=n_clusters,
Expand Down
8 changes: 4 additions & 4 deletions qcware/serialization/transforms/transform_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
themselves for particular types (those go in the helpers file).
"""
from functools import wraps
from typing import Any, Callable, Mapping, Optional
from typing import Any, Callable, Mapping, Optional, Dict

from qcware.serialization.serialize_quasar import (
list_to_pauli,
Expand Down Expand Up @@ -40,7 +40,7 @@
from toolz.dicttoolz import update_in


def update_with_replacers(d: dict[str, Any], replacers: Mapping[str, Callable]):
def update_with_replacers(d: Dict[str, Any], replacers: Mapping[str, Callable]):
"""for all (k,f) in replacers, updates the dict entry marked by k by calling the
function f on the value"""
result = d.copy()
Expand All @@ -50,7 +50,7 @@ def update_with_replacers(d: dict[str, Any], replacers: Mapping[str, Callable]):
return result


_to_wire_arg_replacers: dict[str, dict[str, Callable]] = {}
_to_wire_arg_replacers: Dict[str, Dict[str, Callable]] = {}


def client_args_to_wire(method_name: str, **kwargs):
Expand All @@ -66,7 +66,7 @@ def client_args_to_wire(method_name: str, **kwargs):
)


_from_wire_arg_replacers: dict[str, dict[str, Callable]] = {}
_from_wire_arg_replacers: Dict[str, Dict[str, Callable]] = {}


def replace_server_args_from_wire(method_name: str):
Expand Down
6 changes: 3 additions & 3 deletions qcware/serialization/transforms/transform_results.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Callable, Optional, cast
from typing import Callable, Optional, cast, Dict

import numpy
from decouple import config
Expand Down Expand Up @@ -28,7 +28,7 @@
to_wire,
)

_to_wire_result_replacers: dict[str, Callable] = {}
_to_wire_result_replacers: Dict[str, Callable] = {}


def debug_is_set() -> bool:
Expand Down Expand Up @@ -61,7 +61,7 @@ def server_result_to_wire(method_name: str, worker_result: object):
return f(worker_result)


_from_wire_result_replacers: dict[str, Callable] = {}
_from_wire_result_replacers: Dict[str, Callable] = {}


def client_result_from_wire(method_name: str, worker_result: object):
Expand Down
5 changes: 3 additions & 2 deletions qcware/types/optimization/results/results_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from qcware.types.optimization.problem_spec import BinaryProblem
from qcware.types.optimization.results import utils
from qcware.types.optimization.variable_types import domain_bit_values
from typing import Dict


class Sample(pydantic.BaseModel):
bitstring: Tuple[int, ...]
value: int
occurrences: int = 1

@pydantic.validator("occurrences")
@pydantic.validator("occurrences", allow_reuse=True)
def positive_occurrences(cls, v):
if v <= 0:
raise ValueError(
Expand All @@ -30,7 +31,7 @@ def str_bitstring(self, domain: Domain):
"""Write the sample bitstring in a format like '011' or '+--'."""
return binary_ints_to_binstring(bl=self.bitstring, domain=domain)

def convert(self, mapping: dict[int, int]) -> "Sample":
def convert(self, mapping: Dict[int, int]) -> "Sample":
return Sample(
bitstring=tuple(mapping[i] for i in self.bitstring),
value=self.value,
Expand Down
4 changes: 2 additions & 2 deletions qcware/types/qml/fit_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
as additional internal data.
"""

from typing import Optional, Union
from typing import Optional, Union, Tuple

import numpy.typing
import quasar
Expand All @@ -23,7 +23,7 @@ class FitDataBase(BaseModel):
loader_mode: str
num_measurements: int
absolute: bool
opt_shape: Optional[tuple[int, int]]
opt_shape: Optional[Tuple[int, int]]


class QNearestCentroidFitData(FitDataBase):
Expand Down
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tox]
skipsdist = true
envlist = py37, py38, py39, py310

[testenv]
setenv =
QCWARE_HOST=http://localhost:5454
QCWARE_API_KEY=QCWARE
whitelist_externals = poetry
commands =
poetry install -v
poetry run pytest -k cpu

0 comments on commit 5d3cb70

Please sign in to comment.