Spaces:
Runtime error
Runtime error
Commit
·
ca609d2
1
Parent(s):
c228a82
mend modal
Browse files
app.py
CHANGED
|
@@ -1,29 +1,21 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
|
|
|
| 4 |
from modal import Function
|
| 5 |
-
from pathlib import Path
|
| 6 |
|
| 7 |
def init_modal():
|
| 8 |
-
"""Initialize Modal with token"""
|
| 9 |
try:
|
| 10 |
token = os.environ.get('MODAL_TOKEN')
|
| 11 |
if not token:
|
| 12 |
st.error("MODAL_TOKEN not found in environment variables")
|
| 13 |
return False
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
modal_dir.mkdir(exist_ok=True)
|
| 18 |
|
| 19 |
-
|
| 20 |
-
config_path = modal_dir / 'config.toml'
|
| 21 |
-
config_content = f'''[default]
|
| 22 |
-
token = "{token}"
|
| 23 |
-
'''
|
| 24 |
-
config_path.write_text(config_content)
|
| 25 |
-
|
| 26 |
-
st.success("Modal configuration created successfully")
|
| 27 |
return True
|
| 28 |
|
| 29 |
except Exception as e:
|
|
@@ -39,11 +31,6 @@ def main():
|
|
| 39 |
st.write("Environment Variables:")
|
| 40 |
st.write({k: "***" if k == "MODAL_TOKEN" else v
|
| 41 |
for k, v in os.environ.items()})
|
| 42 |
-
|
| 43 |
-
# Show Modal config if it exists
|
| 44 |
-
config_path = Path.home() / '.modal' / 'config.toml'
|
| 45 |
-
if config_path.exists():
|
| 46 |
-
st.write("Modal config exists at:", str(config_path))
|
| 47 |
|
| 48 |
# Initialize Modal
|
| 49 |
if not init_modal():
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
+
import modal
|
| 5 |
from modal import Function
|
|
|
|
| 6 |
|
| 7 |
def init_modal():
|
| 8 |
+
"""Initialize Modal with direct token"""
|
| 9 |
try:
|
| 10 |
token = os.environ.get('MODAL_TOKEN')
|
| 11 |
if not token:
|
| 12 |
st.error("MODAL_TOKEN not found in environment variables")
|
| 13 |
return False
|
| 14 |
|
| 15 |
+
# Set Modal token directly
|
| 16 |
+
modal.token = token
|
|
|
|
| 17 |
|
| 18 |
+
st.success("Modal token set successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
return True
|
| 20 |
|
| 21 |
except Exception as e:
|
|
|
|
| 31 |
st.write("Environment Variables:")
|
| 32 |
st.write({k: "***" if k == "MODAL_TOKEN" else v
|
| 33 |
for k, v in os.environ.items()})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Initialize Modal
|
| 36 |
if not init_modal():
|