def registered_providers(): """Return the currently registered providers. .. deprecated:: 0.6+ After 0.6, this function is deprecated. Please use the methods in `qiskit.IBMQ` instead (`active_accounts()`). """ warnings.warn( 'registered_providers() will be deprecated after 0.6. Please ' 'use the qiskit.IBMQ.active_accounts() method instead.', DeprecationWarning) return IBMQ.active_accounts()
def __init__(self, wires, provider=None, backend="ibmq_qasm_simulator", shots=1024, **kwargs): token = os.getenv("IBMQX_TOKEN") or kwargs.get("ibmqx_token", None) url = os.getenv("IBMQX_URL") or kwargs.get("ibmqx_url", None) if token is not None: # token was provided by the user, so attempt to enable an # IBM Q account manually ibmq_kwargs = {"url": url} if url is not None else {} IBMQ.enable_account(token, **ibmq_kwargs) else: # turn off deprecation warnings # TODO: remove IBM Q v1 API calls when fully deprecated with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) # check if an IBM Q account is already active. # # * IBMQ v1 credentials stored in active_accounts(). # If no accounts are active, it returns [] # # * IBMQ v2 credentials stored in active_account(). # If no accounts are active, it returns None. if IBMQ.active_account() is None and not IBMQ.active_accounts(): # no active account try: # attempt to load a v1 account stored on disk IBMQ.load_accounts() except IBMQAccountError: try: # attempt to load a v2 account stored on disk IBMQ.load_account() except IBMQAccountError: # attempt to enable an account manually using # a provided token raise IBMQAccountError( "No active IBM Q account, and no IBM Q token provided." ) from None # IBM Q account is now enabled # get a provider p = provider or IBMQ.get_provider() super().__init__(wires=wires, provider=p, backend=backend, shots=shots, **kwargs)