Edwin Salguero
commited on
Commit
·
b2fb4a4
1
Parent(s):
81fb9e2
Add comprehensive debug logging to track FRED API key loading and propagation
Browse files- frontend/app.py +6 -1
- streamlit_app.py +5 -0
frontend/app.py
CHANGED
|
@@ -89,10 +89,13 @@ def load_config():
|
|
| 89 |
|
| 90 |
# Try multiple sources for FRED API key
|
| 91 |
fred_key = os.getenv('FRED_API_KEY')
|
|
|
|
| 92 |
if not fred_key:
|
| 93 |
try:
|
| 94 |
fred_key = st.secrets.get("FRED_API_KEY")
|
| 95 |
-
|
|
|
|
|
|
|
| 96 |
pass
|
| 97 |
|
| 98 |
print("DEBUG: Final FRED_API_KEY =", fred_key)
|
|
@@ -100,6 +103,8 @@ def load_config():
|
|
| 100 |
# Update global variables
|
| 101 |
FRED_API_KEY = fred_key or ''
|
| 102 |
REAL_DATA_MODE = FRED_API_KEY and FRED_API_KEY != 'your-fred-api-key-here'
|
|
|
|
|
|
|
| 103 |
|
| 104 |
try:
|
| 105 |
from config import Config
|
|
|
|
| 89 |
|
| 90 |
# Try multiple sources for FRED API key
|
| 91 |
fred_key = os.getenv('FRED_API_KEY')
|
| 92 |
+
print(f"DEBUG: load_config() - FRED_API_KEY from os.getenv = {fred_key}")
|
| 93 |
if not fred_key:
|
| 94 |
try:
|
| 95 |
fred_key = st.secrets.get("FRED_API_KEY")
|
| 96 |
+
print(f"DEBUG: load_config() - FRED_API_KEY from st.secrets = {fred_key}")
|
| 97 |
+
except Exception as e:
|
| 98 |
+
print(f"DEBUG: load_config() - Error getting from st.secrets: {e}")
|
| 99 |
pass
|
| 100 |
|
| 101 |
print("DEBUG: Final FRED_API_KEY =", fred_key)
|
|
|
|
| 103 |
# Update global variables
|
| 104 |
FRED_API_KEY = fred_key or ''
|
| 105 |
REAL_DATA_MODE = FRED_API_KEY and FRED_API_KEY != 'your-fred-api-key-here'
|
| 106 |
+
print(f"DEBUG: load_config() - Updated FRED_API_KEY = {FRED_API_KEY}")
|
| 107 |
+
print(f"DEBUG: load_config() - Updated REAL_DATA_MODE = {REAL_DATA_MODE}")
|
| 108 |
|
| 109 |
try:
|
| 110 |
from config import Config
|
streamlit_app.py
CHANGED
|
@@ -9,8 +9,13 @@ load_dotenv()
|
|
| 9 |
|
| 10 |
# 2. Grab the key from env OR Cloud secrets
|
| 11 |
fred_key = os.getenv("FRED_API_KEY") or st.secrets.get("FRED_API_KEY")
|
|
|
|
|
|
|
|
|
|
| 12 |
if not fred_key:
|
| 13 |
st.error("❌ FRED API not available. Please configure your FRED_API_KEY.")
|
|
|
|
|
|
|
| 14 |
st.stop()
|
| 15 |
|
| 16 |
# 3. Propagate it into the actual env namespace only
|
|
|
|
| 9 |
|
| 10 |
# 2. Grab the key from env OR Cloud secrets
|
| 11 |
fred_key = os.getenv("FRED_API_KEY") or st.secrets.get("FRED_API_KEY")
|
| 12 |
+
print(f"DEBUG: FRED_API_KEY from os.getenv = {os.getenv('FRED_API_KEY')}")
|
| 13 |
+
print(f"DEBUG: FRED_API_KEY from st.secrets = {st.secrets.get('FRED_API_KEY')}")
|
| 14 |
+
print(f"DEBUG: Final fred_key = {fred_key}")
|
| 15 |
if not fred_key:
|
| 16 |
st.error("❌ FRED API not available. Please configure your FRED_API_KEY.")
|
| 17 |
+
st.info("Available environment variables: " + str(list(os.environ.keys())))
|
| 18 |
+
st.info("Available secrets keys: " + str(list(st.secrets.keys())))
|
| 19 |
st.stop()
|
| 20 |
|
| 21 |
# 3. Propagate it into the actual env namespace only
|