# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import asyncio
from abc import ABC, abstractmethod
from typing import Any, Dict, Union
from braket.tasks.annealing_quantum_task_result import AnnealingQuantumTaskResult
from braket.tasks.gate_model_quantum_task_result import GateModelQuantumTaskResult
[docs]class QuantumTask(ABC):
"""An abstraction over a quantum task on a quantum device."""
@property
@abstractmethod
def id(self) -> str:
"""str: The task ID."""
[docs] @abstractmethod
def cancel(self) -> None:
"""Cancel the quantum task."""
[docs] @abstractmethod
def state(self) -> str:
"""str: State of the quantum task"""
[docs] @abstractmethod
def result(self) -> Union[GateModelQuantumTaskResult, AnnealingQuantumTaskResult]:
"""
Union[GateModelQuantumTaskResult, AnnealingQuantumTaskResult]: Get the quantum task result.
Call async_result if you want the result in an asynchronous way.
"""
[docs] @abstractmethod
def async_result(self) -> asyncio.Task:
"""asyncio.Task: Get the quantum task result asynchronously."""