Skip to content

Commit

Permalink
Reduce chance of save-jobs.ipynb failing in CI (#2386)
Browse files Browse the repository at this point in the history
The problem is `service.jobs()` by default only gets the past 10 jobs.
Usually this is fine, but there's a chance the past 10 jobs we've
submitted have all been cancelled or have failed.

This PR reduces the change of CI failing by increasing the number of
jobs we collect. We can remove the limit by setting `limit=None`, but
this takes too long to execute. I've picked 1000 as a compromise.

***

This is ready for review, but don't merge until after #2382 is merged.
When that happens, I'll pull main and re-run this notebook to update it.
  • Loading branch information
frankharkins authored Nov 26, 2024
1 parent c77b259 commit bc03c60
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
32 changes: 20 additions & 12 deletions docs/guides/save-jobs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
"\n",
"```\n",
"qiskit[all]~=1.2.4\n",
"qiskit-ibm-runtime~=0.33.2\n",
"qiskit-aer~=0.15.1\n",
"qiskit-ibm-runtime~=0.31.0\n",
"qiskit-serverless~=0.17.1\n",
"qiskit-ibm-catalog~=0.1\n",
"qiskit-serverless~=0.18.0\n",
"qiskit-ibm-catalog~=0.2\n",
"qiskit-addon-sqd~=0.8.0\n",
"qiskit-addon-utils~=0.1.0\n",
"qiskit-addon-aqc-tensor~=0.1.2\n",
"qiskit-addon-obp~=0.1.0\n",
"scipy~=1.14.1\n",
"pyscf~=2.7.0\n",
"```\n",
"</details>"
]
Expand Down Expand Up @@ -62,9 +68,9 @@
{
"data": {
"text/plain": [
"[<RuntimeJob('cwj8a5r9r49g00893azg', 'sampler')>,\n",
" <RuntimeJob('cwj82600r6b0008psmrg', 'noise-learner')>,\n",
" <RuntimeJob('cwj7w400r6b0008psm4g', 'sampler')>]"
"[<RuntimeJob('cwxg5cdtdtng0087gwpg', 'estimator')>,\n",
" <RuntimeJob('cwvgyah997wg008xvkgg', 'sampler')>,\n",
" <RuntimeJob('cwvg6e95v39g008hm670', 'noise-learner')>]"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -107,22 +113,24 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/z_/6s4ntyps5lsb232v7f82201r0000gn/T/ipykernel_5474/2704799770.py:3: DeprecationWarning: In a future release of qiskit-ibm-runtime no sooner than 3 months after the release date of 0.30.0, RuntimeJob.status() will be returned as a string instead of an instance of `JobStatus`.\n",
" successful_job = next(j for j in service.jobs() if j.status().name == \"DONE\")\n"
"/var/folders/z_/6s4ntyps5lsb232v7f82201r0000gn/T/ipykernel_42305/3090032923.py:4: DeprecationWarning: In a future release of qiskit-ibm-runtime no sooner than 3 months after the release date of 0.30.0, RuntimeJob.status() will be returned as a string instead of an instance of `JobStatus`.\n",
" j for j in service.jobs(limit=1000) if j.status().name == \"DONE\"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cwj8a5r9r49g00893azg\n"
"cwvgyah997wg008xvkgg\n"
]
}
],
"source": [
"# Get ID of most recent successful job for demonstration.\n",
"# This will not work if you've never successfully run a job.\n",
"successful_job = next(j for j in service.jobs() if j.status().name == \"DONE\")\n",
"successful_job = next(\n",
" j for j in service.jobs(limit=1000) if j.status().name == \"DONE\"\n",
")\n",
"job_id = successful_job.job_id()\n",
"print(job_id)"
]
Expand All @@ -136,7 +144,7 @@
{
"data": {
"text/plain": [
"PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(<shape=(100,), num_shots=4096, num_bits=2>), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan(<start='2024-11-01 07:37:02', stop='2024-11-01 07:39:03', size=409600>)])}, 'version': 2})"
"PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(<shape=(100,), num_shots=4096, num_bits=2>), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan(<start='2024-11-15 09:06:56', stop='2024-11-15 09:09:21', size=409600>)])}, 'version': 2})"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -203,7 +211,7 @@
{
"data": {
"text/plain": [
"PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(<shape=(100,), num_shots=4096, num_bits=2>), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan(<start='2024-11-01 07:37:02', stop='2024-11-01 07:39:03', size=409600>)])}, 'version': 2})"
"PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(<shape=(100,), num_shots=4096, num_bits=2>), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan(<start='2024-11-15 09:06:56', stop='2024-11-15 09:09:21', size=409600>)])}, 'version': 2})"
]
},
"execution_count": 5,
Expand Down
2 changes: 1 addition & 1 deletion scripts/config/notebook-testing.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ notebooks_normal_test = [
"docs/guides/operators-overview.ipynb",
"docs/guides/pulse.ipynb",
"docs/guides/save-circuits.ipynb",
"docs/guides/save-jobs.ipynb",
"docs/guides/dynamic-circuits-considerations.ipynb",
"docs/guides/get-qpu-information.ipynb",
"docs/guides/visualize-results.ipynb",
Expand Down Expand Up @@ -47,7 +48,6 @@ notebooks_exclude = [
"docs/guides/ibm-circuit-function.ipynb",
"docs/guides/qiskit-addons-sqd-get-started.ipynb",
"docs/guides/fractional-gates.ipynb",
"docs/guides/save-jobs.ipynb",
]

# The following notebooks submit jobs that can be mocked with a simulator
Expand Down

0 comments on commit bc03c60

Please sign in to comment.