import streamlit as st from snowflake.snowpark import Session from snowflake.snowpark.context import get_active_session from snowflake.snowpark.exceptions import SnowparkSessionException from common.functions import get_upload_status from common.local_connection import get_connection_parameters try: session = get_active_session() except SnowparkSessionException: connection_params = get_connection_parameters("fileupload") session = Session.builder.configs(connection_params).create() if "upload_name" not in st.session_state: st.session_state.upload_name = None st.subheader("Here you check status of uploaded file") st.write( "Background processes usually take 2-3 minutes. Please type the upload name in the below field:" ) upload_name = st.text_input(label="Upload name", key="upload_name") if st.session_state.upload_name == "": button_disabled = True else: button_disabled = False btn = st.button("Check status", disabled=button_disabled) if btn: st.write("Latest status:") ok_rows, failed_data = get_upload_status(upload_name, session) st.write(f"Nr of rows succesfully processed: {ok_rows}") if failed_data.shape[0] > 0: st.write("Failed rows by reason: ") st.table(failed_data)