def register_and_get_operational_backends(*args, provider_class=IBMQProvider, **kwargs): try: for provider in q_registered_providers(): if isinstance(provider, provider_class): q_unregister(provider) logger.debug( "Provider '{}' unregistered with Qiskit successfully.". format(provider_class)) break except Exception as e: logger.debug( "Failed to unregister provider '{}' with Qiskit: {}".format( provider_class, str(e))) preferences = Preferences() if args or kwargs or preferences.get_token() is not None: try: q_register(*args, provider_class=provider_class, **kwargs) logger.debug( "Provider '{}' registered with Qiskit successfully.". format(provider_class)) except Exception as e: logger.debug( "Failed to register provider '{}' with Qiskit: {}".format( provider_class, str(e))) backends = available_backends() backends = [ x for x in backends if x not in QuantumAlgorithm.UNSUPPORTED_BACKENDS ] return backends
def register_and_get_operational_backends(qconfig): try: for provider in q_registered_providers(): if isinstance(provider,IBMQProvider): q_unregister(provider) logger.debug("Provider 'IBMQProvider' unregistered with Qiskit successfully.") break except Exception as e: logger.debug("Failed to unregister provider 'IBMQProvider' with Qiskit: {}".format(str(e))) if qconfig is not None: hub = qconfig.config.get('hub', None) group = qconfig.config.get('group', None) project = qconfig.config.get('project', None) proxies = qconfig.config.get('proxies', None) verify = qconfig.config.get('verify', True) try: q_register(qconfig.APItoken, provider_class=IBMQProvider, url=qconfig.config["url"], hub=hub, group=group, project=project, proxies=proxies, verify=verify) logger.debug("Provider 'IBMQProvider' registered with Qiskit successfully.") except Exception as e: logger.debug("Failed to register provider 'IBMQProvider' with Qiskit: {}".format(str(e))) backends = available_backends() backends = [x for x in backends if x not in QuantumAlgorithm.UNSUPPORTED_BACKENDS] return backends