Coverage for src/braket/tasks/local_quantum_task.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# http://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License.
14import asyncio
15import uuid
16from typing import Union
18from braket.tasks import AnnealingQuantumTaskResult, GateModelQuantumTaskResult, QuantumTask
21class LocalQuantumTask(QuantumTask):
22 """ A task containing the results of a local simulation.
24 Since this class is instantiated with the results, cancel() and run_async() are unsupported.
25 """
27 def __init__(self, result: Union[GateModelQuantumTaskResult, AnnealingQuantumTaskResult]):
28 self._id = uuid.uuid4()
29 self._result = result
31 @property
32 def id(self) -> str:
33 return str(self._id)
35 def cancel(self) -> None:
36 raise NotImplementedError("Cannot cancel completed local task")
38 def state(self) -> str:
39 return "COMPLETED"
41 def result(self) -> Union[GateModelQuantumTaskResult, AnnealingQuantumTaskResult]:
42 return self._result
44 def async_result(self) -> asyncio.Task:
45 # TODO: Allow for asynchronous simulation
46 raise NotImplementedError("Asynchronous local simulation unsupported")