Skip to content
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

change: Remove throw from local task cancellation #856

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/braket/tasks/local_quantum_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about using pass here. What would your thoughts be if we instead used a log line indicating local tasks are already complete on instantiation or some better worded statement?


def state(self) -> str:
return "COMPLETED"
Expand Down
1 change: 0 additions & 1 deletion test/unit_tests/braket/tasks/test_local_quantum_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def test_result():
assert TASK.result() == RESULT


@pytest.mark.xfail(raises=NotImplementedError)
def test_cancel():
TASK.cancel()

Expand Down