-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieve old jobs #1099
Retrieve old jobs #1099
Changes from 6 commits
eca82ac
8d43014
cd0c096
6e99d1a
1595418
61b465b
4096202
ef32c65
7296cc4
b83ee90
ab8ecfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -164,6 +164,22 @@ def backends( | |||||
superstaq_backends.append(self.get_backend(backend.target)) | ||||||
return superstaq_backends | ||||||
|
||||||
def retrieve_job(self, job_id: str) -> qss.SuperstaqJob: | ||||||
"""Gets a job that has been created on the Superstaq API. | ||||||
|
||||||
Args: | ||||||
job_id: The UUID of the job. Jobs are assigned these numbers by the server during the | ||||||
creation of the job. | ||||||
|
||||||
Returns: | ||||||
A `qss.SuperstaqJob` which can be queried for status or results. | ||||||
|
||||||
Raises: | ||||||
~gss.SuperstaqServerException: If there was an error accessing the API. | ||||||
""" | ||||||
job = self._client.fetch_jobs([job_id]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should also be able to multi-circuit jobs (via a comma-separated job_id), e.g.
Suggested change
(and with the logic below updated accordingly) in this case we'll also probably want to check that all the retrieved jobs have the same target, and if not throw an error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We opted to fetch one job to match the implementation in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
service = css.Service()
job = service.create_job(
[
cirq.Circuit(cirq.measure(cirq.q(0))),
cirq.Circuit(cirq.X(cirq.q(0)), cirq.measure(cirq.q(0)))
],
target="ss_unconstrained_simulator",
method="dry-run",
)
print(job.job_id()) # will have a comma, e.g. "bc58eb54-5787-4328-bd45-a53f0cd609c,66f63a82-822d-43f0-8c1d-dce1923ec67"
new_job = service.get_job(job.job_id())
print(new_job.counts(0)) # {"0": 1000}
print(new_job.counts(1)) # {"1": 1000} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad! I looked at the docstring for def get_job(self, job_id: str) -> css.job.Job:
"""Gets a job that has been created on the Superstaq API.
Args:
job_id: The UUID of the job. Jobs are assigned these numbers by the server during the
creation of the job.
Returns:
A `css.Job` which can be queried for status or results.
Raises:
~gss.SuperstaqServerException: If there was an error accessing the API.
"""
return css.job.Job(client=self._client, job_id=job_id) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yeah that's confusing lol. i think the idea was that a job id with commas is still just a single "job id", but for a multi-circuit job? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that makes sense. |
||||||
return qss.SuperstaqJob(self.get_backend(job[job_id]["target"]), job_id) | ||||||
|
||||||
def resource_estimate( | ||||||
self, circuits: qiskit.QuantumCircuit | Sequence[qiskit.QuantumCircuit], target: str | ||||||
) -> gss.ResourceEstimate | list[gss.ResourceEstimate]: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to
get_job
forcirq-superstaq
parity