def status(self): return BackendStatus( backend_name=self.name(), backend_version=self.configuration().backend_version, operational=True, pending_jobs=0, status_msg='')
def status(self): """Return backend status. Returns: BackendStatus: the status of the backend. """ return BackendStatus(backend_name=self.name(), backend_version=self.configuration().backend_version, operational=True, pending_jobs=0, status_msg='')
class TestBackendConfiguration(QiskitTestCase): """Test the BackendStatus class.""" def setUp(self): """Test backend status for one of the fake backends""" super().setUp() self.backend_status = BackendStatus("my_backend", "1.0", True, 2, "online") def test_repr(self): """Test representation methods of BackendStatus""" self.assertIsInstance(self.backend_status.__repr__(), str) repr_html = self.backend_status._repr_html_() self.assertIsInstance(repr_html, str) self.assertIn(self.backend_status.backend_name, repr_html) def test_fake_backend_status(self): """Test backend status for one of the fake backends""" fake_backend = FakeLondon() backend_status = fake_backend.status() self.assertIsInstance(backend_status, BackendStatus)
def status(self): """Return the online backend status. Returns: BackendStatus: The status of the backend. Raises: LookupError: If status for the backend can't be found. IBMQBackendError: If the status can't be formatted properly. """ api_status = self._api.backend_status(self.name()) try: return BackendStatus.from_dict(api_status) except ValidationError as ex: raise LookupError("Couldn't get backend status: {0}".format(ex))
def status(self) -> BackendStatus: """Return the backend status. Returns: The status of the backend. Raises: IBMQBackendApiProtocolError: If the status for the backend cannot be formatted properly. """ api_status = self._api_client.backend_status(self.name()) try: return BackendStatus.from_dict(api_status) except TypeError as ex: raise IBMQBackendApiProtocolError( 'Unexpected return value received from the server when ' 'getting backend status: {}'.format(str(ex))) from ex
def __init__(self, configuration: BackendConfiguration, provider: 'accountprovider.AccountProvider', credentials: Credentials, api: AccountClient) -> None: """Initialize remote backend for IBM Quantum Experience. Args: configuration: configuration of backend. provider: provider. credentials: credentials. api: api for communicating with the Quantum Experience. """ super().__init__(configuration, provider, credentials, api) self._status = BackendStatus( backend_name=self.name(), backend_version=self.configuration().backend_version, operational=False, pending_jobs=0, status_msg='This backend is no longer available.')
def __init__(self, configuration: BackendConfiguration, provider: 'accountprovider.AccountProvider', credentials: Credentials, api: AccountClient) -> None: """IBMQRetiredBackend constructor. Args: configuration: Backend configuration. provider: IBM Quantum Experience account provider credentials: IBM Quantum Experience credentials. api: IBM Quantum Experience client used to communicate with the server. """ super().__init__(configuration, provider, credentials, api) self._status = BackendStatus( backend_name=self.name(), backend_version=self.configuration().backend_version, operational=False, pending_jobs=0, status_msg='This backend is no longer available.')
def status(self) -> BackendStatus: # now = datetime.now() # windows = self._aws_device.properties.service.executionWindows # is_in_execution_window = windows. status: str = self._aws_device.status backend_status: BackendStatus = BackendStatus( backend_name=self.name(), backend_version=self.version(), operational=False, pending_jobs=0, # TODO status_msg=status ) if status == 'ONLINE': backend_status.operational = True elif status == 'OFFLINE': backend_status.operational = False else: backend_status.operational = False return backend_status
def status(self) -> BackendStatus: """Return the backend status. Note: If the returned :class:`~qiskit.providers.models.BackendStatus` instance has ``operational=True`` but ``status_msg="internal"``, then the backend is accepting jobs but not processing them. Returns: The status of the backend. Raises: IBMQBackendApiProtocolError: If the status for the backend cannot be formatted properly. """ api_status = self._api_client.backend_status(self.name()) try: return BackendStatus.from_dict(api_status) except TypeError as ex: raise IBMQBackendApiProtocolError( 'Unexpected return value received from the server when ' 'getting backend status: {}'.format(str(ex))) from ex
def __init__( self, configuration: Union[QasmBackendConfiguration, PulseBackendConfiguration], provider: "ibm_provider.IBMProvider", api_client: AccountClient, ) -> None: """IBMRetiredBackend constructor. Args: configuration: Backend configuration. provider: IBM Quantum account provider. credentials: IBM Quantum credentials. api_client: IBM Quantum client used to communicate with the server. """ super().__init__(configuration, provider, api_client) self._status = BackendStatus( backend_name=self.name, backend_version=self.configuration().backend_version, operational=False, pending_jobs=0, status_msg="This backend is no longer available.", )
def setUp(self): """Test backend status for one of the fake backends""" super().setUp() self.backend_status = BackendStatus("my_backend", "1.0", True, 2, "online")