import os
import sys

cwd = os.getcwd()
qiskit_dir = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(cwd))))
sys.path.append(qiskit_dir)

from qiskit import BasicAer, execute
from qiskit.circuit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.compiler import transpile
from qiskit.tools.parallel import parallel_map
from qiskit.tools.monitor import job_monitor
from qiskit.tools.events import TextProgressBar
from qiskit.tools.jupyter import *

sim_backend = BasicAer.get_backend("qasm_simulator")

import time


def func(_):
    time.sleep(0.1)
    return 0

HTMLProgressBar()
parallel_map(func, list(range(10)));

%qiskit_progress_bar
parallel_map(func, list(range(10)));

TextProgressBar()
parallel_map(func, list(range(10)));

%qiskit_progress_bar -t text
parallel_map(func, list(range(10)));

q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)

qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)

HTMLProgressBar()
qobj = transpile([qc] * 20, backend=sim_backend)

job_sim2 = execute([qc] * 10, backend=sim_backend)
job_monitor(job_sim2)