File size: 2,165 Bytes
a963d65 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#!/usr/bin/env python3
"""
Modal Configuration Setup for FhirFlame
Following https://modal.com/docs/reference/modal.config
"""
import os
import modal
from dotenv import load_dotenv
def setup_modal_config():
"""Set up Modal configuration properly"""
# Load environment variables from .env file
load_dotenv()
# Check if Modal tokens are properly configured
token_id = os.getenv("MODAL_TOKEN_ID")
token_secret = os.getenv("MODAL_TOKEN_SECRET")
if not token_id or not token_secret:
print("β Modal tokens not found!")
print("\nπ Setup Modal Authentication:")
print("1. Visit https://modal.com and create an account")
print("2. Run: modal token new")
print("3. Or set environment variables:")
print(" export MODAL_TOKEN_ID=ak-...")
print(" export MODAL_TOKEN_SECRET=as-...")
return False
print("β
Modal tokens found")
print(f" Token ID: {token_id[:10]}...")
print(f" Token Secret: {token_secret[:10]}...")
# Test Modal connection by creating a simple app
try:
# This will verify the tokens work by creating an app instance
app = modal.App("fhirflame-config-test")
print("β
Modal client connection successful")
return True
except Exception as e:
if "authentication" in str(e).lower() or "token" in str(e).lower():
print(f"β Modal authentication failed: {e}")
print("\nπ§ Fix authentication:")
print("1. Check your tokens are correct")
print("2. Run: modal token new")
print("3. Or update your .env file")
else:
print(f"β Modal connection failed: {e}")
return False
def get_modal_app():
"""Get properly configured Modal app"""
if not setup_modal_config():
raise Exception("Modal configuration failed")
return modal.App("fhirflame-medical-scaling")
if __name__ == "__main__":
success = setup_modal_config()
if success:
print("π Modal configuration is ready!")
else:
print("β Modal configuration needs attention") |