Skip to content

Commit 14ea3d0

Browse files
abbycrossjohannesgreinerEric-Arellano
authored
method get_job_by_id() missing in Qiskit Function Intro (#2629)
Closes #2627 which was opened by @johannesgreiner. Johannes, can you provide more info on the fix please? --------- Co-authored-by: Johannes Greiner <[email protected]> Co-authored-by: Eric Arellano <[email protected]>
1 parent 7bdb091 commit 14ea3d0

File tree

1 file changed

+55
-26
lines changed

1 file changed

+55
-26
lines changed

docs/guides/functions.ipynb

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "a47ac9aa-4bb9-4240-806e-9beabfd2dda2",
5+
"id": "97b94d47-ba58-4251-91f2-93097e50f2c9",
66
"metadata": {},
77
"source": [
88
"# Introduction to Qiskit Functions\n",
@@ -22,7 +22,7 @@
2222
},
2323
{
2424
"cell_type": "markdown",
25-
"id": "0be0fe02-bc50-45a6-aaf6-2120dac862c2",
25+
"id": "a4c425ca-c6c6-4232-b4b9-b2a365d10ad9",
2626
"metadata": {
2727
"tags": [
2828
"version-info"
@@ -45,7 +45,7 @@
4545
},
4646
{
4747
"cell_type": "markdown",
48-
"id": "098d8fd4-1558-40df-a1b1-ad70fdef8863",
48+
"id": "1fe03d0f-c7bb-439b-b98e-91ca400b62fc",
4949
"metadata": {},
5050
"source": [
5151
"Qiskit Functions simplify and accelerate utility-scale algorithm discovery and application development, by abstracting away parts of the quantum software development workflow. In this way, Qiskit Functions free up time normally spent hand-writing code and fine-tuning experiments.\n",
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"cell_type": "markdown",
64-
"id": "df18227b-787a-4dc6-a8c7-7abd0f67110c",
64+
"id": "5e5b0531-f286-4573-8b1e-664ca5496d2d",
6565
"metadata": {},
6666
"source": [
6767
"Functions are provided by IBM&reg; and third-party partners. Each is performant for specific workload characteristics and have unique performance-tuning options. Premium Plan users can get started with IBM Qiskit Functions for free, or procure a license from one of the partners who have contributed a function to the catalog.\n",
@@ -103,7 +103,7 @@
103103
{
104104
"cell_type": "code",
105105
"execution_count": 1,
106-
"id": "e872c222-aee9-40eb-8778-9a8e5434a11c",
106+
"id": "6699700c-ae26-4c10-8d09-05ee77a1afb7",
107107
"metadata": {},
108108
"outputs": [],
109109
"source": [
@@ -115,7 +115,7 @@
115115
},
116116
{
117117
"cell_type": "markdown",
118-
"id": "80441467-1d9a-4107-8570-22afa6e369f7",
118+
"id": "a00d2d76-dfbe-4a92-be82-8dea393ff12a",
119119
"metadata": {},
120120
"source": [
121121
"<LegacyContent>\n",
@@ -151,7 +151,7 @@
151151
},
152152
{
153153
"cell_type": "markdown",
154-
"id": "6f2d0a37-1c6d-4cad-a9ce-c4d05c7aaaf1",
154+
"id": "374939e2-54ac-4b72-92df-19a5fe9ec352",
155155
"metadata": {},
156156
"source": [
157157
"<LegacyContent>\n",
@@ -172,7 +172,7 @@
172172
},
173173
{
174174
"cell_type": "markdown",
175-
"id": "5154cbea-ccfa-42ea-a9ef-c31699c3b2c0",
175+
"id": "e3cada45-0364-4096-8481-6eb99d43c656",
176176
"metadata": {},
177177
"source": [
178178
"4. After you have authenticated, you can list the functions from the Qiskit Functions Catalog that you have access to:"
@@ -181,7 +181,7 @@
181181
{
182182
"cell_type": "code",
183183
"execution_count": 2,
184-
"id": "55b73ad8-6e3b-4b76-8ba5-ae7ea339ffcc",
184+
"id": "275b4b94-7656-403e-8997-941c03c7ef55",
185185
"metadata": {},
186186
"outputs": [
187187
{
@@ -210,7 +210,7 @@
210210
},
211211
{
212212
"cell_type": "markdown",
213-
"id": "a1c73799-30ec-44dc-b4b9-06e59d521d8c",
213+
"id": "de09ad8c-bd6d-4a02-8b24-7bb73beca811",
214214
"metadata": {},
215215
"source": [
216216
"### Run enabled functions\n",
@@ -221,7 +221,7 @@
221221
{
222222
"cell_type": "code",
223223
"execution_count": 3,
224-
"id": "4ac22236-2a34-46fb-890f-30d6ba70081e",
224+
"id": "65a26da5-f537-44ed-9cb4-b335518d009d",
225225
"metadata": {},
226226
"outputs": [],
227227
"source": [
@@ -230,7 +230,7 @@
230230
},
231231
{
232232
"cell_type": "markdown",
233-
"id": "deb844d3-051a-4db1-b0a1-4ba9801ef95e",
233+
"id": "0a5f87e4-3082-4ec5-a7ae-7ddb5c35632a",
234234
"metadata": {},
235235
"source": [
236236
"Each Qiskit Function has custom inputs, options, and outputs. Check the specific documentation pages for the function you want to run for more information. By default, all users can only run one function job at a time:"
@@ -241,6 +241,7 @@
241241
"execution_count": null,
242242
"id": "139ac1d5-3727-4f44-a26c-0d8a1d8a58f2",
243243
"metadata": {
244+
"scrolled": true,
244245
"tags": [
245246
"remove-cell"
246247
]
@@ -289,7 +290,7 @@
289290
},
290291
{
291292
"cell_type": "markdown",
292-
"id": "b1518e8e-04ea-4e4e-9f30-10f87dd4ee82",
293+
"id": "113d4382-a987-492d-9e12-b66d3b955bc4",
293294
"metadata": {},
294295
"source": [
295296
"### Check job status\n",
@@ -311,7 +312,7 @@
311312
{
312313
"cell_type": "code",
313314
"execution_count": 6,
314-
"id": "d811be20-cf0d-4070-a126-b40af6a33132",
315+
"id": "d0574d73-0966-4426-b2f5-94df72a07caa",
315316
"metadata": {},
316317
"outputs": [
317318
{
@@ -331,7 +332,7 @@
331332
},
332333
{
333334
"cell_type": "markdown",
334-
"id": "8e6528b5-c36f-48e1-bb2f-2416ccb12902",
335+
"id": "439fbefc-f7d3-4e6e-b3e6-61a3664ac5e9",
335336
"metadata": {},
336337
"source": [
337338
"### Retrieve results\n",
@@ -342,7 +343,7 @@
342343
{
343344
"cell_type": "code",
344345
"execution_count": 7,
345-
"id": "04f6a446-fbc6-438a-bc07-00fc9d551d83",
346+
"id": "45e302d8-f3c2-4868-8b7c-6d451f6119a9",
346347
"metadata": {},
347348
"outputs": [
348349
{
@@ -360,7 +361,7 @@
360361
},
361362
{
362363
"cell_type": "markdown",
363-
"id": "76c32136-f449-454c-896b-ff9d0edf9abc",
364+
"id": "d809d8fa-479c-4c3b-81d7-3408925cec68",
364365
"metadata": {},
365366
"source": [
366367
"You can also cancel a job at any time:"
@@ -369,7 +370,7 @@
369370
{
370371
"cell_type": "code",
371372
"execution_count": 8,
372-
"id": "7ddc2394-64a9-4fdd-bb3d-7729433fcd9c",
373+
"id": "0e55d4d6-4680-4671-907f-35aac16971ef",
373374
"metadata": {},
374375
"outputs": [
375376
{
@@ -389,7 +390,7 @@
389390
},
390391
{
391392
"cell_type": "markdown",
392-
"id": "5b5d7c8d-7a96-41e2-93aa-528513acdd21",
393+
"id": "1ef980bc-9030-4f8a-84d6-a0abd15923ac",
393394
"metadata": {},
394395
"source": [
395396
"### List previously run jobs run with Qiskit Functions\n",
@@ -399,8 +400,8 @@
399400
},
400401
{
401402
"cell_type": "code",
402-
"execution_count": 9,
403-
"id": "c1a2832b-1ca3-4ef1-9a8a-3f3804b3aedf",
403+
"execution_count": 8,
404+
"id": "4becfe13-68dd-481d-bb43-fc502c254623",
404405
"metadata": {},
405406
"outputs": [
406407
{
@@ -418,7 +419,7 @@
418419
" <Job | eaa2db93-0d2f-4b52-9f1b-a69fc03dc3d6>]"
419420
]
420421
},
421-
"execution_count": 9,
422+
"execution_count": 8,
422423
"metadata": {},
423424
"output_type": "execute_result"
424425
}
@@ -430,7 +431,35 @@
430431
},
431432
{
432433
"cell_type": "markdown",
433-
"id": "9137071a-e39c-4b66-afbd-697db38cc670",
434+
"id": "af7fa72a-f272-43ff-800d-5ae37dd42b2b",
435+
"metadata": {},
436+
"source": [
437+
"If you already have the job ID for a certain job, you can retrieve the job with `catalog.get_job_by_id()`:"
438+
]
439+
},
440+
{
441+
"cell_type": "code",
442+
"execution_count": null,
443+
"id": "18d87f07-8a8e-4b93-80d0-7c07e49272e2",
444+
"metadata": {},
445+
"outputs": [],
446+
"source": [
447+
"# First, get the most recent job that has been executed.\n",
448+
"latest_job = old_jobs[0]\n",
449+
"\n",
450+
"# We can also get that same job with get_job_by_id\n",
451+
"job_by_id = catalog.get_job_by_id(latest_job.job_id)\n",
452+
"\n",
453+
"# Verify that the job is the same using both retrieval methods.\n",
454+
"assert job_by_id == latest_job\n",
455+
"\n",
456+
"# Print the job_id for this job.\n",
457+
"print(job_by_id.job_id)"
458+
]
459+
},
460+
{
461+
"cell_type": "markdown",
462+
"id": "e15f89f8-925d-4d13-8fb8-80ad1d8ac7f6",
434463
"metadata": {},
435464
"source": [
436465
"### Fetch error messages\n",
@@ -441,7 +470,7 @@
441470
{
442471
"cell_type": "code",
443472
"execution_count": 10,
444-
"id": "abfdf746-bc46-4df7-85b3-4a7a61ab7ca7",
473+
"id": "3e9d090a-7eb4-476e-92f8-6871803a704d",
445474
"metadata": {},
446475
"outputs": [
447476
{
@@ -458,7 +487,7 @@
458487
},
459488
{
460489
"cell_type": "markdown",
461-
"id": "7c8c3e5d-1de2-4fed-be03-d134dc3fd907",
490+
"id": "709b39ca-5dbd-42c0-830c-1248c2e5d63c",
462491
"metadata": {},
463492
"source": [
464493
"## Next steps\n",
@@ -494,5 +523,5 @@
494523
"title": "Introduction to Qiskit Functions"
495524
},
496525
"nbformat": 4,
497-
"nbformat_minor": 2
526+
"nbformat_minor": 4
498527
}

0 commit comments

Comments
 (0)