def pc_modal_active()

in UI/nl2sqlstudio_ui.py [0:0]


        def pc_modal_active() -> None:
            """
                Modal output when the Project Configuration button on the
                Side bar is pressed
            """
            pc_modal = st.session_state.pc_modal
            if pc_modal.is_open():
                with pc_modal.container():
                    project = st.text_input('Mention the GCP project name')
                    dataset = st.text_input(
                        'Specify the BigQuery dataset name'
                        )
                    uploaded_file = st.file_uploader(
                        "Choose the Metadata Cache file"
                        )
                    with open('sample_metadata.json', 'rb') as f:
                        st.download_button('Download Sample Metadata file',
                                           f,
                                           file_name='sample_metadata.json')
                    if st.button("Save configuration"):
                        if uploaded_file is not None:
                            # To read file as bytes:
                            url = os.getenv('EXECUTORS')
                            # To convert to a string based IO:
                            stringio = StringIO(
                                uploaded_file.getvalue().decode("utf-8")
                                )

                            logger.info(
                                f"Uploading file : {uploaded_file.name}"
                                )
                            # To read file as string:
                            string_data = stringio.read()
                            files = {'file': (uploaded_file.name, string_data)}
                            token = f"Bearer {st.session_state.access_token}"
                            body = {"proj_name": project,
                                    "bq_dataset": dataset,
                                    "metadata_file": uploaded_file.name}
                            headers = {"Content-type": "application/json",
                                       "Authorization": token}
                            # url = "http://localhost:5000"
                            executors_list = ['CORE_EXECUTORS',
                                              'LITE_EXECUTORS']
                            for executor in executors_list:
                                url = os.getenv(executor)
                                logger.info(
                                    f"(Project config for : {executor}"
                                    )
                                _ = requests.post(
                                    url=url+"/projconfig",
                                    data=json.dumps(body),
                                    headers=headers,
                                    timeout=None
                                    )

                                _ = requests.post(
                                    url=url+"/uploadfile",
                                    headers={"Authorization": token},
                                    files=files,
                                    timeout=None
                                    )

                        pc_modal.close()