-
Notifications
You must be signed in to change notification settings - Fork 99
method get_job_by_id() missing in Qiskit Function Intro #2629
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
base: main
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
One or more of the following people are relevant to this code: |
So basically we'd want a few lines showing how to take an existing job_id and pass it to |
e.g. we can use the existing |
Co-authored-by: Johannes Greiner <[email protected]>
docs/guides/functions.ipynb
Outdated
"metadata": {}, | ||
"source": [ | ||
"```\n", | ||
"<Job | b1486233-3f59-4c19-b52d-6ad729b891cc>\n", |
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.
@Eric-Arellano when there is no print statement, would the assert statement still give an output of any kind? (What is here is left over from when there was a print statement, so I need to update it)
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.
No, the assert
does not give output. Rather than hardcoding the output as markdown like this, it's better to update the code
block to directly call print()
and rely on nb-tester
(i.e. run tox
) to generate the output.
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.
I've been running the notebook locally to get outputs. Should I be leaving them blank and leave it to tox to supply the outputs?
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.
Running it locally is fine too
This reverts commit 731bc4c.
Co-authored-by: Eric Arellano <[email protected]>
"output_type": "execute_result" | ||
} | ||
], | ||
"outputs": [], |
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.
This PR makes a bad revert
"outputs": [], | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'d76b6abf-3a16-4dd6-a9ac-a7ffa780d2f7'" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], |
"id": "af7fa72a-f272-43ff-800d-5ae37dd42b2b", | ||
"metadata": {}, | ||
"source": [ | ||
"To retrieve a job's job_id by its position in the list, use `catalog.get_job_by_id()`:" |
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.
@johannesgreiner this seems wrong to me to say "by its position in the list"? I think this should instead read as something like:
If you already have the job ID for a certain job, you can retrieve it with
catalog.get_job_by_id()
:
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.
Isn't the job id the thing you're retrieving, and rather you're trying to find the nth job id in a list?
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.
No, get_job_by_id
is when you already have a particular job ID (some string) and you are getting a job (I think https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/runtime-job-v2?)
and rather you're trying to find the nth job id in a list?
That's what you're doing with old_jobs[0]
: you're getting the nth job where old_jobs
is all the jobs that have run, sorted by date.
"# Print the job_id for the latest job.\n", | ||
"print(latest_job)" |
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.
job_by_id and latest_job should be the same thing. It might be clearer if we use job_by_id since that is what we are demoing
"# Print the job_id for the latest job.\n", | |
"print(latest_job)" | |
"# Print the job_id for this job.\n", | |
"print(job_by_id.job_id)" |
"# Verify that the job ID is the same using both retrieval methods.\n", | ||
"assert job_by_id.job_id == latest_job.job_id\n", |
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.
I think this will actually be more clear. It demonstrates that the entire Job is the same, not just the ID.
"# Verify that the job ID is the same using both retrieval methods.\n", | |
"assert job_by_id.job_id == latest_job.job_id\n", | |
"# Verify that the job is the same using both retrieval methods.\n", | |
"assert job_by_id == latest_job\n", |
"latest_job = old_jobs[0]\n", | ||
"job_by_id = catalog.get_job_by_id(latest_job.job_id)\n", |
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.
"latest_job = old_jobs[0]\n", | |
"job_by_id = catalog.get_job_by_id(latest_job.job_id)\n", | |
"latest_job = old_jobs[0]\n", | |
"\n", | |
"# We can also get that same job with get_job_by_id\n", | |
"job_by_id = catalog.get_job_by_id(latest_job.job_id)\n", |
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Get the most recent job that has been executed.\n", |
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.
"# Get the most recent job that has been executed.\n", | |
"# First, get the most recent job that has been executed.\n", |
@@ -132,6 +132,7 @@ ipywidgets | |||
iqft | |||
iswap | |||
ISYM | |||
jobid |
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.
Not sure this should be in the dictionary, I think we should either say " job ID" in a sentence, or use code stying (jobid
) if referring to the method / variable.
Closes #2627 which was opened by @johannesgreiner. Johannes, can you provide more info on the fix please?