Archisman Karmakar
commited on
Commit
·
e999632
1
Parent(s):
6a4f32b
DB URI FIX
Browse files
transformation_and_Normalization/transformationNormalization_main.py
CHANGED
@@ -43,7 +43,7 @@ current_tokenizer = None
|
|
43 |
# Enabling Resource caching
|
44 |
|
45 |
# Load environment variables from .env
|
46 |
-
|
47 |
|
48 |
# @st.cache_resource
|
49 |
# DATABASE_URL = os.environ.get("DATABASE_URL")
|
@@ -184,6 +184,17 @@ def enable_ui():
|
|
184 |
|
185 |
# Function to increment progress dynamically
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
def update_progress(progress_bar, start, end, delay=0.1):
|
189 |
for i in range(start, end + 1, 5): # Increment in steps of 5%
|
@@ -514,12 +525,12 @@ def transform_and_normalize():
|
|
514 |
# print("anon_key:", os.environ.get("anon_key"))
|
515 |
# print("table3_name:", os.environ.get("table3_name"))
|
516 |
# load_dotenv(dotenv_path=env_path)
|
517 |
-
load_dotenv()
|
518 |
# supabase: Client = create_client(os.environ.get("SUPABASE_URL"), os.environ.get("anon_key"))
|
519 |
# response = supabase.table(os.environ.get("table3_name")).insert(data_to_insert, returning="minimal").execute()
|
520 |
try:
|
521 |
-
supabase: Client = create_client(
|
522 |
-
response = supabase.table("SUPABASE_DB_TACHYGRAPHY_DB_STAGE3_TABLE").insert(data_to_insert, returning="minimal").execute()
|
523 |
st.success("Feedback submitted successfully!")
|
524 |
st.session_state.feedback_submitted = True
|
525 |
except Exception as e:
|
|
|
43 |
# Enabling Resource caching
|
44 |
|
45 |
# Load environment variables from .env
|
46 |
+
load_dotenv()
|
47 |
|
48 |
# @st.cache_resource
|
49 |
# DATABASE_URL = os.environ.get("DATABASE_URL")
|
|
|
184 |
|
185 |
# Function to increment progress dynamically
|
186 |
|
187 |
+
def get_env_variable(var_name):
|
188 |
+
# Try os.environ first (this covers local development and HF Spaces)
|
189 |
+
value = os.environ.get(var_name)
|
190 |
+
if value is None:
|
191 |
+
# Fall back to st.secrets if available (e.g., on Streamlit Cloud)
|
192 |
+
try:
|
193 |
+
value = st.secrets[var_name]
|
194 |
+
except KeyError:
|
195 |
+
value = None
|
196 |
+
return value
|
197 |
+
|
198 |
|
199 |
def update_progress(progress_bar, start, end, delay=0.1):
|
200 |
for i in range(start, end + 1, 5): # Increment in steps of 5%
|
|
|
525 |
# print("anon_key:", os.environ.get("anon_key"))
|
526 |
# print("table3_name:", os.environ.get("table3_name"))
|
527 |
# load_dotenv(dotenv_path=env_path)
|
528 |
+
# load_dotenv()
|
529 |
# supabase: Client = create_client(os.environ.get("SUPABASE_URL"), os.environ.get("anon_key"))
|
530 |
# response = supabase.table(os.environ.get("table3_name")).insert(data_to_insert, returning="minimal").execute()
|
531 |
try:
|
532 |
+
supabase: Client = create_client(get_env_variable("SUPABASE_DB_TACHYGRAPHY_DB_URL"), get_env_variable("SUPABASE_DB_TACHYGRAPHY_ANON_API_KEY"))
|
533 |
+
response = supabase.table(get_env_variable("SUPABASE_DB_TACHYGRAPHY_DB_STAGE3_TABLE")).insert(data_to_insert, returning="minimal").execute()
|
534 |
st.success("Feedback submitted successfully!")
|
535 |
st.session_state.feedback_submitted = True
|
536 |
except Exception as e:
|