Sumedhzz commited on
Commit
c8e0039
·
1 Parent(s): efd5730

Final deployment with cloud bypass

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +16 -8
src/streamlit_app.py CHANGED
@@ -59,15 +59,23 @@ st.markdown("""
59
  # --- CLOUD DATA LOGGING (GOOGLE SHEETS) ---
60
  # This manual approach bypasses the buggy Streamlit "auto-discovery"
61
  def get_connection():
 
 
 
 
 
 
 
 
 
 
 
62
  try:
63
- # 1. Pull the raw strings from the Hugging Face vault
64
- json_secrets = st.secrets.get("GSHEETS_JSON")
65
- sheet_url = st.secrets.get("GSHEETS_URL")
66
-
67
- if not json_secrets or not sheet_url:
68
- st.warning("🚀 System Initializing... Waiting for Cloud Vault Access.")
69
- st.info("Check your HF Settings: Ensure secrets are named GSHEETS_JSON and GSHEETS_URL.")
70
- st.stop()
71
 
72
  # 2. Convert string to a real Python dictionary
73
  creds_dict = json.loads(json_secrets)
 
59
  # --- CLOUD DATA LOGGING (GOOGLE SHEETS) ---
60
  # This manual approach bypasses the buggy Streamlit "auto-discovery"
61
  def get_connection():
62
+ # Use .get() so it doesn't crash if the vault is momentarily empty
63
+ json_secrets = st.secrets.get("GSHEETS_JSON")
64
+ sheet_url = st.secrets.get("GSHEETS_URL")
65
+
66
+ if not json_secrets:
67
+ st.error("❌ 'GSHEETS_JSON' not found in Hugging Face Secrets!")
68
+ st.stop()
69
+ if not sheet_url:
70
+ st.error("❌ 'GSHEETS_URL' not found in Hugging Face Secrets!")
71
+ st.stop()
72
+
73
  try:
74
+ creds_dict = json.loads(json_secrets)
75
+ return st.connection("gsheets", type=GSheetsConnection, credentials=creds_dict), sheet_url
76
+ except Exception as e:
77
+ st.error(f"⚠️ JSON Parsing Error: {e}")
78
+ st.stop()
 
 
 
79
 
80
  # 2. Convert string to a real Python dictionary
81
  creds_dict = json.loads(json_secrets)