Source code for mpqp_scripts.setup_connections

#! /usr/bin/env python3
"""The ``setup_connections`` script helps you configuring the connections for
all the supported remote backends. In time, it will also guide you to retrieve
the tokens, passwords, etc... but for now, it is a prerequisite that you already
have these credentials to use this script.

Information concerning which provider is configured and related credentials are
stored in the ``~/.mpqp`` file."""

import os

os.environ["FOR_DISABLE_CONSOLE_CTRL_HANDLER"] = "1"





[docs]def main_setup(): """Main function of the script, triggering the choice selection, and guiding you through the steps needed to configure each provider access. This function has to be executed from a terminal like environment, allowing you to type tokens and alike.""" from mpqp.execution.connection.aws_connection import setup_aws_braket_account from mpqp.execution.connection.ibm_connection import setup_ibm_account from mpqp.execution.connection.key_connection import config_ionq_key from mpqp.execution.connection.qlm_connection import setup_qlm_account from mpqp.tools.choice_tree import AnswerNode, QuestionNode, run_choice_tree # def no_op(): # return "", [] setup_tree = QuestionNode( "~~~~~ MPQP REMOTE CONFIGURATION ~~~~~", [ AnswerNode("IBM", setup_ibm_account), AnswerNode("QLM", setup_qlm_account), AnswerNode("Amazon Braket", setup_aws_braket_account), AnswerNode("IonQ", config_ionq_key), AnswerNode("Recap", print_config_info), # AnswerNode( # "Cirq", # no_op, # next_question=QuestionNode( # "~~~~~ Cirq REMOTE CONFIGURATION ~~~~~", # [ # AnswerNode("↩ Return", no_op), # ], # ), # ), ], ) # TODO: to avoid having to manually set that, we could add this as an option # to the run choice tree for answer in setup_tree.answers: if answer.label == "Cirq" and answer.next_question is not None: for answer in answer.next_question.answers: answer.next_question = setup_tree else: answer.next_question = setup_tree run_choice_tree(setup_tree)
if __name__ == "__main__": try: main_setup() except KeyboardInterrupt: exit()