From 1284adcdd4ffe982c86d98066b5dbf600fc2f05f Mon Sep 17 00:00:00 2001 From: Stephen Face Date: Fri, 19 Jan 2024 19:34:36 -0800 Subject: [PATCH 1/2] change: Remove throw from local task cancellation --- src/braket/tasks/local_quantum_task.py | 5 +++-- test/unit_tests/braket/tasks/test_local_quantum_task.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/braket/tasks/local_quantum_task.py b/src/braket/tasks/local_quantum_task.py index 69a0f1bd6..edd20cb22 100644 --- a/src/braket/tasks/local_quantum_task.py +++ b/src/braket/tasks/local_quantum_task.py @@ -25,7 +25,7 @@ class LocalQuantumTask(QuantumTask): """A quantum task containing the results of a local simulation. - Since this class is instantiated with the results, cancel() and run_async() are unsupported. + Since this class is instantiated with the results, run_async() is unsupported. """ def __init__( @@ -43,7 +43,8 @@ def id(self) -> str: def cancel(self) -> None: """Cancel the quantum task.""" - raise NotImplementedError("Cannot cancel completed local task") + # A LocalQuantumTask is already completed, so there is nothing to cancel + pass def state(self) -> str: return "COMPLETED" diff --git a/test/unit_tests/braket/tasks/test_local_quantum_task.py b/test/unit_tests/braket/tasks/test_local_quantum_task.py index 6b583c608..1a6802e70 100644 --- a/test/unit_tests/braket/tasks/test_local_quantum_task.py +++ b/test/unit_tests/braket/tasks/test_local_quantum_task.py @@ -46,7 +46,6 @@ def test_result(): assert TASK.result() == RESULT -@pytest.mark.xfail(raises=NotImplementedError) def test_cancel(): TASK.cancel() From 13b6781cc665e3f56f02d335810a8041ca306b7f Mon Sep 17 00:00:00 2001 From: Stephen Face Date: Mon, 22 Jan 2024 17:19:01 -0800 Subject: [PATCH 2/2] update local cancel docstring --- src/braket/tasks/local_quantum_task.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/braket/tasks/local_quantum_task.py b/src/braket/tasks/local_quantum_task.py index edd20cb22..e8f4d4756 100644 --- a/src/braket/tasks/local_quantum_task.py +++ b/src/braket/tasks/local_quantum_task.py @@ -42,8 +42,11 @@ def id(self) -> str: return str(self._id) def cancel(self) -> None: - """Cancel the quantum task.""" - # A LocalQuantumTask is already completed, so there is nothing to cancel + """Attempt to cancel the quantum task. + + Since this class is instantiated with the results, there is nothing to cancel. Attempting + to cancel an already completed task is not an error. + """ pass def state(self) -> str: