pentarosarium commited on
Commit
37fc8c9
·
1 Parent(s): cba456b

add token debugging

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -6,11 +6,12 @@ import os
6
  def init_modal():
7
  """Initialize Modal with token from environment"""
8
  try:
9
- # Import modal and directly set token from environment
10
- import modal
11
  token = os.environ.get('MODAL_TOKEN')
12
  if not token:
13
- raise ValueError("MODAL_TOKEN environment variable not set")
 
 
14
 
15
  # Create token file
16
  token_dir = os.path.expanduser("~/.modal")
@@ -19,6 +20,7 @@ def init_modal():
19
  with open(os.path.join(token_dir, "token"), "w") as f:
20
  f.write(token)
21
 
 
22
  return True
23
  except Exception as e:
24
  st.error(f"Failed to initialize Modal: {str(e)}")
@@ -27,9 +29,14 @@ def init_modal():
27
  def main():
28
  st.title("Financial Statement Analyzer")
29
 
 
 
 
 
 
 
30
  # Initialize Modal
31
  if not init_modal():
32
- st.error("Could not initialize Modal. Please check your token configuration.")
33
  return
34
 
35
  uploaded_files = st.file_uploader(
 
6
  def init_modal():
7
  """Initialize Modal with token from environment"""
8
  try:
9
+ # Check if token exists in environment
 
10
  token = os.environ.get('MODAL_TOKEN')
11
  if not token:
12
+ st.error("MODAL_TOKEN not found in environment variables")
13
+ st.info("Please add MODAL_TOKEN to Hugging Face Space secrets")
14
+ return False
15
 
16
  # Create token file
17
  token_dir = os.path.expanduser("~/.modal")
 
20
  with open(os.path.join(token_dir, "token"), "w") as f:
21
  f.write(token)
22
 
23
+ st.success("Modal token configured successfully")
24
  return True
25
  except Exception as e:
26
  st.error(f"Failed to initialize Modal: {str(e)}")
 
29
  def main():
30
  st.title("Financial Statement Analyzer")
31
 
32
+ # Show environment info (for debugging)
33
+ if st.checkbox("Show Debug Info"):
34
+ st.write("Environment Variables:")
35
+ st.write({k: "***" if k == "MODAL_TOKEN" else v
36
+ for k, v in os.environ.items()})
37
+
38
  # Initialize Modal
39
  if not init_modal():
 
40
  return
41
 
42
  uploaded_files = st.file_uploader(