Skip to content

Commit 1ca053b

Browse files
Merge branch 'dev' of https://github.com/ColibrITD-SAS/mpqp into dev
2 parents 40473d2 + 8e9ef94 commit 1ca053b

File tree

6 files changed

+52
-38
lines changed

6 files changed

+52
-38
lines changed

docs/execution-extras.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ __________
6464
Connection setup script
6565
-----------------------
6666

67-
.. automodule:: mpqp.execution.connection.setup_connections
67+
.. automodule:: mpqp_scripts.setup_connections
6868

6969
The details on how to get these information can be found in the section
7070
:ref:`Setting up a remote device`.

mpqp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pyright: reportUnusedImport=false
22
from mpqp.core.circuit import QCircuit
3+
from mpqp.core.instruction import Instruction
34
from mpqp.core.instruction.barrier import Barrier
45
from mpqp.core.languages import Language
5-
from mpqp.core.instruction import Instruction

mpqp/tools/choice_tree.py

+20-15
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,29 @@ def run_choice_tree(question: QuestionNode):
5050
Args:
5151
question: Root question from which the choice tree will start
5252
"""
53-
# 3M-TODO: allow exit with Ctrl+C and Q
53+
# 3M-TODO: allow exit with Q
5454
prev_args = []
5555
prev_message = ""
5656
next_question = question
57-
while True:
58-
option, _ = pick(
59-
list(map(lambda a: a.label, next_question.answers)) + ["Exit"],
60-
prev_message + "\n\n" + next_question.label,
61-
indicator="=>",
62-
)
63-
if option == "Exit":
64-
return
65-
selected_answer = find(next_question.answers, lambda a: a.label == option)
66-
prev_message, prev_args = selected_answer.action(*prev_args)
67-
next_question = selected_answer.next_question
68-
if next_question is None:
69-
pick(["Press 'Enter' to continue"], prev_message, indicator="")
70-
return
57+
try:
58+
while True:
59+
option, _ = pick(
60+
list(map(lambda a: a.label, next_question.answers)) + ["Exit"],
61+
prev_message + "\n\n" + next_question.label,
62+
indicator="=>",
63+
)
64+
if option == "Exit":
65+
return
66+
selected_answer = find(next_question.answers, lambda a: a.label == option)
67+
prev_message, prev_args = selected_answer.action(*prev_args)
68+
next_question = selected_answer.next_question
69+
if next_question is None:
70+
pick(["Press 'Enter' to continue"], prev_message, indicator="")
71+
return
72+
73+
except KeyboardInterrupt:
74+
print()
75+
pass
7176

7277

7378
# Example:

mpqp/execution/connection/setup_connections.py mpqp_scripts/setup_connections.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
#! /usr/bin/env python3
2-
"""This script helps you configuring the connections for all the supported
3-
remote backends. In time, it will also guide you to retrieve the tokens,
4-
passwords, etc... but for now, it is a prerequisite that you already have these
5-
credentials to use this script.
2+
"""The ``setup_connections`` script helps you configuring the connections for
3+
all the supported remote backends. In time, it will also guide you to retrieve
4+
the tokens, passwords, etc... but for now, it is a prerequisite that you already
5+
have these credentials to use this script.
66
7-
Information concerning which provider is configured and related
8-
credentials are stored in the ``~/.mpqp`` file."""
7+
Information concerning which provider is configured and related credentials are
8+
stored in the ``~/.mpqp`` file."""
99

10-
import mpqp.execution.connection.aws_connection as awsc
11-
import mpqp.execution.connection.env_manager as env_m
12-
import mpqp.execution.connection.ibm_connection as ibmqc
13-
import mpqp.execution.connection.qlm_connection as qlmc
14-
from mpqp.tools.choice_tree import AnswerNode, QuestionNode, run_choice_tree
15-
from mpqp.tools.errors import IBMRemoteExecutionError
10+
import os
11+
12+
os.environ["FOR_DISABLE_CONSOLE_CTRL_HANDLER"] = "1"
1613

1714

1815
def print_config_info():
16+
import mpqp.execution.connection.aws_connection as awsc
17+
import mpqp.execution.connection.env_manager as env_m
18+
import mpqp.execution.connection.ibm_connection as ibmqc
19+
from mpqp.tools.errors import IBMRemoteExecutionError
20+
1921
"""Prints the info concerning each provider's registered account."""
2022
print("===== IBM Quantum info : ===== ")
2123
try:
@@ -45,6 +47,10 @@ def print_config_info():
4547
def main_setup():
4648
"""Function called by the script bellow to setup all connections or to get
4749
information about the existing ones."""
50+
import mpqp.execution.connection.aws_connection as awsc
51+
import mpqp.execution.connection.ibm_connection as ibmqc
52+
import mpqp.execution.connection.qlm_connection as qlmc
53+
from mpqp.tools.choice_tree import AnswerNode, QuestionNode, run_choice_tree
4854

4955
setup_tree = QuestionNode(
5056
"~~~~~ MPQP REMOTE CONFIGURATION ~~~~~",
@@ -63,4 +69,7 @@ def main_setup():
6369

6470

6571
if __name__ == "__main__":
66-
main_setup()
72+
try:
73+
main_setup()
74+
except KeyboardInterrupt:
75+
exit()

requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ numpy>=1.23.2
22
scipy>=1.11.4
33
amazon-braket-sdk==1.64.2
44
aws-configure==2.1.8
5-
boto3>=1.34.5
65
myqlm==1.9.3
76
qlmaas==1.9.1
87
myqlm-interop==1.9.3
9-
qiskit==0.45.0
10-
qiskit_aer==0.13.1
11-
qiskit_ibm_provider==0.7.2
12-
qiskit-ibm-runtime==0.17.0
8+
qiskit==1.0.0
9+
qiskit_aer
10+
qiskit_ibm_provider
11+
qiskit-ibm-runtime==0.21.2
1312
python_dotenv==1.0.0
1413
typeguard>=4.1.5
1514
pylatexenc==2.10
@@ -18,5 +17,6 @@ sympy==1.10.1
1817
pick==2.2.0
1918
termcolor==2.4.0
2019
aenum==3.1.15
21-
symengine==0.9.2
20+
symengine==0.11
21+
boto3>=1.34.5
2222
cirq==1.3.0

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import find_packages, setup
22

33
with open("README.md", "r", encoding="utf-8") as f:
44
long_description = f.read()
@@ -32,7 +32,7 @@
3232
packages=find_packages(include=["mpqp*"]),
3333
entry_points={
3434
"console_scripts": [
35-
"setup_connections = mpqp.execution.connection.setup_connections:main_setup",
35+
"setup_connections = mpqp_scripts.setup_connections:main_setup",
3636
]
3737
},
3838
project_urls={

0 commit comments

Comments
 (0)