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

Commit

Permalink
fix: test for retrieving job results through runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Wagner committed Aug 30, 2023
1 parent e947ce7 commit 33b3e02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 54 deletions.
16 changes: 2 additions & 14 deletions planqk/qiskit/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class PlanqkQuantumProvider(Provider):

def __init__(self, access_token: str=None):
def __init__(self, access_token: str = None):
"""Initialize the PlanQK provider.
Args:
access_token (str): access token used for authentication with PlanQK. If not token is provided,
Expand Down Expand Up @@ -44,19 +44,7 @@ def backends(self, provider: PROVIDER = None, **kwargs):
backend_info.id for backend_info in backend_dtos
if provider is None or backend_info.provider == provider
]

# backends = []
# for backend_dto in supported_backend_infos:
# backends.append(
# PlanqkBackend(
# backend_info=backend_dto,
# provider=self,
# name=backend_dto.name,
# description=f"PlanQK Backend: {backend_dto.hardware_provider.name} {backend_dto.name}.",
# online_date=datetime.strptime(backend_dto.updated_at, "%Y-%m-%d %H:%M:%S"),
# backend_version="2",
# )
# )
# TODO filter QPUs
return supported_backend_ids

def get_backend(self, name=None, provider: PROVIDER = None, **kwargs):
Expand Down
34 changes: 0 additions & 34 deletions planqk/qiskit/runtime_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,42 +112,8 @@ def run(self,
shots=shots,
input_params=input_params)

# TODO return RuntimeJob
return PlanqkRuntimeJob(backend=backend, job_details=job_request)

# _PlanqkClient.submit_job()
#
#
# response = self._api_client.program_run(
# program_id=program_id,
# backend_name=qrt_options.backend,
# params=inputs,
# image=qrt_options.image,
# hgp=hgp_name,
# log_level=qrt_options.log_level,
# session_id=session_id,
# job_tags=qrt_options.job_tags,
# max_execution_time=qrt_options.max_execution_time,
# start_session=start_session,
# session_time=qrt_options.session_time,
#
#
# backend = self.backend(name=response["backend"], instance=hgp_name)
#
# job = RuntimeJob(
# backend=backend,
# api_client=self._api_client,
# client_params=self._client_params,
# job_id=response["id"],
# program_id=program_id,
# params=inputs,
# user_callback=callback,
# result_decoder=result_decoder,
# image=qrt_options.image,
# service=self,
# )
# return job

@property
def channel(self) -> str:
"""Return the channel type used.
Expand Down
12 changes: 6 additions & 6 deletions tests/acceptance/backends/ibm_primitive_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _run_job(self) -> PlanqkJob:
with Session(self.planqk_provider, backend=planqk_backend.name, max_time=None) as session:
sampler = Sampler(session=session)
self._planqk_job = sampler.run(self.get_input_circuit(), shots=10) # TODO memory=True

# https://qiskit.org/ecosystem/ibm-runtime/tutorials/how-to-getting-started-with-sampler.html
session.close()

Expand All @@ -82,14 +81,15 @@ def should_run_multiple_jobs_in_session(self):
session.close()

def should_retrieve_job(self):
planqk_job = self._run_job()
job_id = planqk_job.id
panqk_rt_job = self._run_job()
job_id = panqk_rt_job.id
planqk_backend_id = self.get_backend_id()

# Get job via Qiskit runtime
exp_job = self.get_provider().job(job_id)
# Get job via Qiskit runtime - returns all jobs in session
exp_jobs = self.get_provider().jobs(backend_name=self.get_provider_backend_name(),
session_id=panqk_rt_job.session_id)
# Get job via PlanQK
planqk_backend = self.planqk_provider.get_backend(planqk_backend_id)
job = planqk_backend.retrieve_job(job_id)

self.assert_job(job, exp_job)
self.assert_job(job, exp_jobs[0])

0 comments on commit 33b3e02

Please sign in to comment.