Skip to content

Commit

Permalink
automated push from 19b6ea5874e91cbb1d8350e947b8ec1cf34c5315
Browse files Browse the repository at this point in the history
  • Loading branch information
Vic Putz committed Jul 21, 2020
1 parent c434df5 commit 3c032c6
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 293 deletions.
5 changes: 4 additions & 1 deletion qcware/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# AUTO-GENERATED FILE - MODIFY AT OWN RISK
# Project: qcware
# Copyright (c) 2019 QC Ware Corp - All Rights Reserved


"""
This is the client library for QC Ware's Forge product,
a SaaS product for solving problems with quantum computing.
Please see the documentation at http://qcware.readthedocs.io
"""
__version__ = '2.0.0a1'
__version__='2.1'
import logging
logger = logging.getLogger('qcware')


from . import qio
from . import circuits
from . import qml
Expand Down
3 changes: 3 additions & 0 deletions qcware/circuits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
# Project: qcware
# Copyright (c) 2019 QC Ware Corp - All Rights Reserved



from .run_backend_method import run_backend_method, async_run_backend_method

46 changes: 19 additions & 27 deletions qcware/circuits/run_backend_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
# Project: qcware
# Copyright (c) 2019 QC Ware Corp - All Rights Reserved



import asyncio
from .. import logger
from ..api_calls import post_call, wait_for_call, handle_result
from ..util.transforms import client_args_to_wire
from ..exceptions import ApiTimeoutError
from ..exceptions import ApiTimeoutError


def run_backend_method(backend: str,
method: str,
kwargs: dict,
api_key: str = None,
host: str = None):
def run_backend_method(backend:str, method:str, kwargs:dict, api_key:str=None, host:str=None):
r"""Runs an arbitrary backend method. This API call is not intended to be used directly by users; rather, it is meant to be called by the QuasarBackend class to transparently delegate class method calls to Forge API endpoints.
Arguments:
Expand All @@ -32,19 +30,14 @@ def run_backend_method(backend: str,
:rtype: object
"""
data = client_args_to_wire('circuits.run_backend_method', **locals())
api_call = post_call('circuits/run_backend_method', data, host=host)
logger.info(
f'API call to circuits.run_backend_method successful. Your API token is {api_call["uid"]}'
)
return handle_result(
wait_for_call(api_key=api_key, host=host, call_token=api_call['uid']))


async def async_run_backend_method(backend: str,
method: str,
kwargs: dict,
api_key: str = None,
host: str = None):
api_call = post_call('circuits/run_backend_method', data, host=host )
logger.info(f'API call to circuits.run_backend_method successful. Your API token is {api_call["uid"]}')
return handle_result(wait_for_call(api_key=api_key,
host=host,
call_token=api_call['uid']))


async def async_run_backend_method(backend:str, method:str, kwargs:dict, api_key:str=None, host:str=None):
r"""Async version of run_backend_method
Runs an arbitrary backend method. This API call is not intended to be used directly by users; rather, it is meant to be called by the QuasarBackend class to transparently delegate class method calls to Forge API endpoints.
Expand All @@ -65,16 +58,15 @@ async def async_run_backend_method(backend: str,
:rtype: object
"""
data = client_args_to_wire('circuits.run_backend_method', **locals())
api_call = post_call('circuits/run_backend_method', data, host=host)
logger.info(
f'API call to circuits.run_backend_method successful. Your API token is {api_call["uid"]}'
)
api_call = post_call('circuits/run_backend_method', data, host=host )
logger.info(f'API call to circuits.run_backend_method successful. Your API token is {api_call["uid"]}')

while True:
try:
return handle_result(
wait_for_call(api_key=api_key,
host=host,
call_token=api_call['uid']))
return handle_result(wait_for_call(api_key=api_key,
host=host,
call_token=api_call['uid']))
except ApiTimeoutError as e:
await asyncio.sleep(5)


3 changes: 2 additions & 1 deletion qcware/config/api_semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# Project: qcware
# Copyright (c) 2019 QC Ware Corp - All Rights Reserved

api_semver = '2.0.0-alpha.1'

api_semver = '3.0.0'
3 changes: 3 additions & 0 deletions qcware/optimization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Project: qcware
# Copyright (c) 2019 QC Ware Corp - All Rights Reserved



from .find_optimal_qaoa_angles import find_optimal_qaoa_angles, async_find_optimal_qaoa_angles

from .solve_binary import solve_binary, async_solve_binary

60 changes: 21 additions & 39 deletions qcware/optimization/find_optimal_qaoa_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@
# Project: qcware
# Copyright (c) 2019 QC Ware Corp - All Rights Reserved



import asyncio
from .. import logger
from ..api_calls import post_call, wait_for_call, handle_result
from ..util.transforms import client_args_to_wire
from ..exceptions import ApiTimeoutError
from ..exceptions import ApiTimeoutError


def find_optimal_qaoa_angles(Q: dict = {},
num_evals: int = 100,
num_min_vals: int = 10,
fastmath_flag_in: bool = True,
precision: int = 30,
api_key: str = None,
host: str = None):
def find_optimal_qaoa_angles(Q:dict={}, num_evals:int=100, num_min_vals:int=10, fastmath_flag_in:bool=True, precision:int=30, api_key:str=None, host:str=None):
r"""Finds the optimal expectation values for a given cost function, to be used in QAOA.
Arguments:
Expand Down Expand Up @@ -50,25 +46,15 @@ def find_optimal_qaoa_angles(Q: dict = {},
:rtype: tuple
"""
data = client_args_to_wire('optimization.find_optimal_qaoa_angles',
**locals())
api_call = post_call('optimization/find_optimal_qaoa_angles',
data,
host=host)
logger.info(
f'API call to optimization.find_optimal_qaoa_angles successful. Your API token is {api_call["uid"]}'
)
return handle_result(
wait_for_call(api_key=api_key, host=host, call_token=api_call['uid']))


async def async_find_optimal_qaoa_angles(Q: dict = {},
num_evals: int = 100,
num_min_vals: int = 10,
fastmath_flag_in: bool = True,
precision: int = 30,
api_key: str = None,
host: str = None):
data = client_args_to_wire('optimization.find_optimal_qaoa_angles', **locals())
api_call = post_call('optimization/find_optimal_qaoa_angles', data, host=host )
logger.info(f'API call to optimization.find_optimal_qaoa_angles successful. Your API token is {api_call["uid"]}')
return handle_result(wait_for_call(api_key=api_key,
host=host,
call_token=api_call['uid']))


async def async_find_optimal_qaoa_angles(Q:dict={}, num_evals:int=100, num_min_vals:int=10, fastmath_flag_in:bool=True, precision:int=30, api_key:str=None, host:str=None):
r"""Async version of find_optimal_qaoa_angles
Finds the optimal expectation values for a given cost function, to be used in QAOA.
Expand Down Expand Up @@ -105,20 +91,16 @@ async def async_find_optimal_qaoa_angles(Q: dict = {},
:rtype: tuple
"""
data = client_args_to_wire('optimization.find_optimal_qaoa_angles',
**locals())
api_call = post_call('optimization/find_optimal_qaoa_angles',
data,
host=host)
logger.info(
f'API call to optimization.find_optimal_qaoa_angles successful. Your API token is {api_call["uid"]}'
)
data = client_args_to_wire('optimization.find_optimal_qaoa_angles', **locals())
api_call = post_call('optimization/find_optimal_qaoa_angles', data, host=host )
logger.info(f'API call to optimization.find_optimal_qaoa_angles successful. Your API token is {api_call["uid"]}')

while True:
try:
return handle_result(
wait_for_call(api_key=api_key,
host=host,
call_token=api_call['uid']))
return handle_result(wait_for_call(api_key=api_key,
host=host,
call_token=api_call['uid']))
except ApiTimeoutError as e:
await asyncio.sleep(5)


Loading

0 comments on commit 3c032c6

Please sign in to comment.