"""
    Quapp Platform Project quapp_qibo_device.py Copyright © CITYNOW Co. Ltd. All rights reserved.
"""
#  Quapp Platform Project
#  quapp_qibo_device.py
#  Copyright © CITYNOW Co. Ltd. All rights reserved.

from quapp_common.data.device.circuit_running_option import CircuitRunningOption
from quapp_common.model.provider.provider import Provider
import time

from .qibo_device import QiboDevice


class QuappQiboDevice(QiboDevice):
    def __init__(self, provider: Provider, device_specification: str):
        super().__init__(provider, device_specification)

    def _create_job(self, circuit, options: CircuitRunningOption):
        self.logger.debug(f'Creating job with {options.shots} shots')

        start_time = time.perf_counter()

        result = str(circuit.execute(nshots=options.shots).to_dict())

        end_time = time.perf_counter()

        execution_time = end_time - start_time

        return  {
            "result": result,
            "execution_time": execution_time
        }



    def _is_simulator(self) -> bool:
        self.logger.debug('Checking if simulator')
        self.logger.debug(f'Simulator: {True}')
        return True
