API_KEY = "5bd4ecfdc74e6680da7c79998259781431661e5326ae2f88eea95dee8f74b87530ba63fbca8105404de4ffd36e4b484631907acff73c805580928218a5ccf0b3"

import qiskit as q
from qiskit import IBMQ,schedule
import numpy as np

import qiskit.pulse as pulse
from qiskit.circuit import Parameter


%matplotlib inline
import sys
sys.path.insert(0, '..') # Add qiskit_runtime directory to the path

IBMQ.save_account(API_KEY)
# Details in: https://qiskit.org/documentation/install.html 

IBMQ.save_account(API_KEY, overwrite=True)
IBMQ.load_account()

provider = IBMQ.get_provider("ibm-q")

for backend in provider.backends():
    try:
        qubit_count = len(backend.properties().quibits)
    except:
        qubit_count = "simulated"
        
    print(f"{backend.name()} has {backend.status().pending_jobs} queued and { qubit_count} qubits")

from qiskit.tools.monitor import job_monitor
backend = provider.get_backend("ibmq_lima")

# Checking for backend support 
# https://github.com/delapuente/qiskit-runtime/#test-server

from qiskit import IBMQ

provider = IBMQ.load_account()
print(f"Do I have access to Qiskit Runtime? {provider.has_service('runtime')}")


backend = provider.backend.ibmq_lima
support_runtime = 'runtime' in backend.configuration().input_allowed
print(f"Does {backend.name()} support Qiskit Runtime? {support_runtime}")


# Get a list of all backends that support runtime.
runtime_backends = provider.backends(input_allowed='runtime')
print(f"Backends that support Qiskit Runtime: {runtime_backends}")
