sf_conn added to UI3

This commit is contained in:
Mayank Aamseek
2024-03-14 17:05:39 +05:30
parent 064146e61c
commit e1f0b880de
2 changed files with 37 additions and 14 deletions
+22 -1
View File
@@ -19,11 +19,32 @@ import dateutil
import util
import anthropic
import re
import snowflake.connector
from sf_conn import get_secret
sf_secrets = get_secret()
conn = snowflake.connector.connect(
user=sf_secrets['user'],
password=sf_secrets['password'],
account="aarete-doczyai",
role = sf_secrets['ROLE'],
warehouse=sf_secrets['warehouse'],
database=sf_secrets['database'],
schema="STG"
)
cur = conn.cursor()
query = 'select * from "TRAINING_DATA_RAW"'
cur.execute(query)
df = pd.DataFrame(cur.fetchall())
REDIRECT_URI = 'https://doczy.aarete.com:8503'
user_list = ['maamseek@aarete.com', 'smahdavian@aarete.com', 'ahinge@aarete.com', 'akadam@aarete.com'
, 'piragavarapu@aarete.com', 'umistry@aarete.com', 'ahutchison@aarete.com', 'bgrunst@aarete.com', 'ddimeglio@aarete.com'
, 'vnair@aarete.com', 'kminhas@aarete.com','dculotta@aarete.com','cbull@aarete.com','sclark@aarete.com']
, 'vnair@aarete.com']
st.set_page_config(layout = "wide")
# Sidebar contents
+15 -13
View File
@@ -31,20 +31,21 @@ def get_secret():
raise e
secret = get_secret_value_response['SecretString']
# Your code goes here.
return secret
get_secret()
# get_secret()
mwaa_env_name = 'doczy-dev-infra-mwaa'
dag_name = 'load_training_results'
mwaa_cli_command = 'dags trigger'
# Create the client with the specified profile
session = boto3.Session()
client = session.client('mwaa', region_name='us-east-2')
def save_to_sf(training_results_file, attempt_logs_file):
mwaa_env_name = 'doczy-dev-infra-mwaa'
dag_name = 'load_training_results'
mwaa_cli_command = 'dags trigger'
# Create the client with the specified profile
session = boto3.Session()
client = session.client('mwaa', region_name='us-east-2')
# get web token
mwaa_cli_token = client.create_cli_token(
Name=mwaa_env_name
@@ -54,8 +55,8 @@ def save_to_sf(training_results_file, attempt_logs_file):
# This section passes the payload to the MWAA CLI
# The file parameters should be added dynamically in streamlit, once the file names are passed while triggering the dag, the data will be ingested
#training_results_file = "training_results_sample.csv"
# attempt_logs_file = "attempt_logs_sample.csv"
training_results_file = "training_results_sample.csv"
attempt_logs_file = "attempt_logs_sample.csv"
# 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"""{{
@@ -77,4 +78,5 @@ def save_to_sf(training_results_file, attempt_logs_file):
return base64.b64decode(mydata['stdout'])
save_to_sf("2024-03-13T17-36_prompt_results.csv", "2024-03-13T17-46_history.csv")
# save_to_sf("s3://doczy-test-bucket/snowflake-temp/2024-03-13T17-36_prompt_results.csv", "s3://doczy-test-bucket/snowflake-temp/2024-03-13T17-46_history.csv")