From bc03c60c52e7f9b3e9062a8435583a1e9254c4cb Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Tue, 26 Nov 2024 11:28:13 +0000 Subject: [PATCH] Reduce chance of `save-jobs.ipynb` failing in CI (#2386) 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. --- docs/guides/save-jobs.ipynb | 32 +++++++++++++++++----------- scripts/config/notebook-testing.toml | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/docs/guides/save-jobs.ipynb b/docs/guides/save-jobs.ipynb index 8ae6c03212b..e316a5579ff 100644 --- a/docs/guides/save-jobs.ipynb +++ b/docs/guides/save-jobs.ipynb @@ -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", "" ] @@ -62,9 +68,9 @@ { "data": { "text/plain": [ - "[,\n", - " ,\n", - " ]" + "[,\n", + " ,\n", + " ]" ] }, "execution_count": 1, @@ -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)" ] @@ -136,7 +144,7 @@ { "data": { "text/plain": [ - "PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan()])}, 'version': 2})" + "PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan()])}, 'version': 2})" ] }, "execution_count": 3, @@ -203,7 +211,7 @@ { "data": { "text/plain": [ - "PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan()])}, 'version': 2})" + "PrimitiveResult([SamplerPubResult(data=DataBin(meas=BitArray(), shape=(100,)), metadata={'circuit_metadata': {}})], metadata={'execution': {'execution_spans': ExecutionSpans([SliceSpan()])}, 'version': 2})" ] }, "execution_count": 5, diff --git a/scripts/config/notebook-testing.toml b/scripts/config/notebook-testing.toml index 8d86fddf29c..6af53638592 100644 --- a/scripts/config/notebook-testing.toml +++ b/scripts/config/notebook-testing.toml @@ -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", @@ -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