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

from quapp_common.config.logging_config import job_logger
from qibo import set_backend

from quapp_common.enum.provider_tag import ProviderTag
from quapp_common.model.provider.provider import Provider

logger = job_logger('QuappQiboProvider')


class QuappQiboProvider(Provider):

    def collect_provider(self):
        return None

    def __init__(self, ):
        super().__init__(ProviderTag.QUAO_QUANTUM_SIMULATOR)

    def get_backend(self, device_specification):

        try:
            set_backend(device_specification)
            return device_specification
        except Exception:
            logger.exception(f'Unsupported device: {device_specification}')
            raise Exception('Unsupported device')