Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PlanQK/planqk-quantum
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.8.4
Choose a base ref
...
head repository: PlanQK/planqk-quantum
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.8.5
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Jul 6, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0d2e7de View commit details
  2. chore(release): v1.8.5

    ## [1.8.5](v1.8.4...v1.8.5) (2023-07-06)
    
    ### Bug Fixes
    
    * use raise_for_status instead of own exception ([0d2e7de](0d2e7de))
    semantic-release-bot committed Jul 6, 2023
    Copy the full SHA
    84cd04e View commit details
Showing with 13 additions and 32 deletions.
  1. +0 −4 planqk/exceptions.py
  2. +12 −27 planqk/qiskit/client/client.py
  3. +1 −1 setup.py
4 changes: 0 additions & 4 deletions planqk/exceptions.py
Original file line number Diff line number Diff line change
@@ -7,9 +7,5 @@ def __str__(self):
return repr(self.message)


class PlanqkClientError(PlanqkError):
pass


class CredentialUnavailableError(PlanqkError):
pass
39 changes: 12 additions & 27 deletions planqk/qiskit/client/client.py
Original file line number Diff line number Diff line change
@@ -8,9 +8,8 @@
import requests

from planqk.credentials import DefaultCredentialsProvider
from planqk.exceptions import PlanqkClientError
from planqk.qiskit.client.backend_dtos import BackendDto
from planqk.qiskit.client.client_dtos import JobDto
from planqk.qiskit.client.backend_dtos import BackendDto, PROVIDER

logger = logging.getLogger(__name__)

@@ -32,7 +31,6 @@ def _dict_values_to_string(obj_values_dict: dict):


class _PlanqkClient(object):

_credentials = None

@classmethod
@@ -48,65 +46,52 @@ def get_backends(cls, name: Optional[str] = None) -> List[BackendDto]:
params["name"] = name

response = requests.get(f"{base_url()}/backends", params=params, headers=headers)
if not response:
raise PlanqkClientError(
f"Error requesting available quantum backends (HTTP {response.status_code}: {response.text})"
)
response.raise_for_status()

return [BackendDto.from_dict(backend_info) for backend_info in response.json()]

@classmethod
def get_backend(cls, backend_id: str):
headers = cls._get_default_headers()
response = requests.get(f"{base_url()}/backends/{backend_id}", headers=headers)
if not response:
raise PlanqkClientError(
f"Error requesting available quantum backends (HTTP {response.status_code}: {response.text})"
)
response.raise_for_status()
return response.json()

@classmethod
def submit_job(cls, job: JobDto) -> str:
#TODO type job request
# TODO: type job request
headers = cls._get_default_headers()
headers["Content-TYPE"] = "application/json"

job_dict = job.__dict__
#_dict_values_to_string(job_dict.get("metadata")) TODO in azure

# TODO: in azure
# _dict_values_to_string(job_dict.get("metadata"))

response = requests.post(f"{base_url()}/jobs", json=job_dict, headers=headers)
if not response:
raise PlanqkClientError(f"Error submitting job (HTTP {response.status_code}: {response.text})")
response.raise_for_status()
return response.json()["id"]

@classmethod
def get_job(cls, job_id: str) -> JobDto:
headers = cls._get_default_headers()
encoded_job_id = urllib.parse.quote_plus(job_id)
response = requests.get(f"{base_url()}/jobs/{encoded_job_id}", headers=headers)
if not response:
raise PlanqkClientError(
f'Error requesting details of job "{job_id}" (HTTP {response.status_code}: {response.text})'
)
response.raise_for_status()
return JobDto.from_dict(response.json())

@classmethod
def get_job_result(cls, job_id: str) -> dict:
headers = cls._get_default_headers()
response = requests.get(f"{base_url()}/jobs/{job_id}/result", headers=headers)
if not response:
raise PlanqkClientError(
f'Error requesting result of job "{job_id}" (HTTP {response.status_code}: {response.text})'
)
response.raise_for_status()
return response.json()

@classmethod
def cancel_job(cls, job_id: str) -> None:
headers = cls._get_default_headers()
response = requests.delete(f"{base_url()}/jobs/{job_id}", headers=headers)
if not response:
raise PlanqkClientError(
f'Error cancelling job "{job_id}" (HTTP {response.status_code}: {response.text})'
)
response.raise_for_status()

@classmethod
def _get_default_headers(cls):
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

setup(
name='planqk-quantum',
version="1.8.4",
version="1.8.5",
author='StoneOne AG',
author_email='info@stoneone.de',
url='https://github.com/planqk/planqk-quantum',