From 087d5431d931e59597ede7b48741be7103b69ca2 Mon Sep 17 00:00:00 2001 From: Mayank Aamseek Date: Tue, 9 Apr 2024 18:00:59 +0530 Subject: [PATCH] save_to_df testing --- streamlit/interface_3.py | 8 ++++---- streamlit/sf_conn.py | 13 +++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/streamlit/interface_3.py b/streamlit/interface_3.py index a36e704..d0b56c1 100644 --- a/streamlit/interface_3.py +++ b/streamlit/interface_3.py @@ -640,10 +640,10 @@ if st.session_state.user_info['mail'] in user_list: st.write(raw_response_text) try: - result_db_store = save_to_sf('load_training_results', training_results_file_name = "results.csv", attempt_logs_file_name = "history.csv") - st.write(result_db_store) - except Exception as e: - st.write(e) + results = save_to_sf('load_training_results', "training_results_file_name", "attempt_logs_file_name", "results.csv", "history.csv") + st.write(results) + except: + st.write("running locally") else: st.write("Access Denied") diff --git a/streamlit/sf_conn.py b/streamlit/sf_conn.py index 3ad45b9..12b3246 100644 --- a/streamlit/sf_conn.py +++ b/streamlit/sf_conn.py @@ -9,7 +9,6 @@ import http.client import base64 import ast import snowflake.connector -import json def get_secret(): @@ -40,8 +39,7 @@ def get_secret(): # TODO: This function needs to be changed to accept Kwargs # The function name should be more generic and cofnigurable -# def save_to_sf(dag_name, conf_1, conf_2, training_results_file, attempt_logs_file): -def save_to_sf(dag_name, **kwargs): +def save_to_sf(dag_name, conf_1, conf_2, training_results_file, attempt_logs_file): mwaa_env_name = 'doczy-dev-infra-mwaa' dag_name = dag_name @@ -65,11 +63,10 @@ def save_to_sf(dag_name, **kwargs): # conf = "{\"" + "training_results_file_name" + "\":\"" + {training_results_file} + "\", \"" + "attempt_logs_file_name" + "\":\"" + {attempt_logs_file} + "\"}".format(training_results_file=training_results_file, attempt_logs_file=attempt_logs_file) conf = f"""{{ - "{list(kwargs.keys())[0]}": "{list(kwargs.values())[0]}", - "{list(kwargs.keys())[1]}": "{list(kwargs.values())[1]}" - }}""" + "{conf_1}": "{training_results_file}", + "{conf_2}": "{attempt_logs_file}" + }}""" - conf1 = json.dumps(kwargs) payload = mwaa_cli_command + " " + dag_name + " --conf '{}'".format(conf) headers = { @@ -81,7 +78,7 @@ def save_to_sf(dag_name, **kwargs): data = res.read() dict_str = data.decode("UTF-8") mydata = ast.literal_eval(dict_str) - return str(conf) + str(conf1) + return payload # save_to_sf("2024-03-13T17-36_prompt_results.csv", "2024-03-14T23-19_history.csv")