Ali2206 commited on
Commit
1eccd08
·
verified ·
1 Parent(s): f7e9489

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +8 -13
config.py CHANGED
@@ -4,9 +4,9 @@ from txagent.txagent import TxAgent
4
  from db.mongo import get_mongo_client
5
  import asyncio
6
  from pyfcm import FCMNotification
7
- from huggingface_hub import get_secret
8
  from datetime import datetime
9
  import httpx
 
10
 
11
  # Logging
12
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(name)s - %(message)s")
@@ -42,19 +42,19 @@ alerts_collection = db["clinical_alerts"]
42
  notifications_collection = db["notifications"]
43
  logger.info("📡 Connected to MongoDB synchronously at %s", datetime.utcnow().isoformat())
44
 
45
- # Retrieve secrets from Hugging Face
46
- FCM_API_KEY = get_secret("FCM_API_KEY")
47
- SECRET_KEY = get_secret("SECRET_KEY")
48
 
49
  if not FCM_API_KEY or not SECRET_KEY:
50
- logger.error("❌ Missing FCM_API_KEY or SECRET_KEY in Hugging Face Secrets")
51
- raise ValueError("FCM_API_KEY and SECRET_KEY must be set in Hugging Face Secrets")
52
 
53
  # FCM settings
54
  push_service = FCMNotification(api_key=FCM_API_KEY)
55
 
56
  # Auth Space URL
57
- AUTH_SPACE_URL = "https://rocketfarmstudios-cps-api.hf.space/auth"
58
 
59
  async def send_push_notification(recipient_email, message):
60
  try:
@@ -108,9 +108,4 @@ def setup_app(app: FastAPI):
108
  async def startup_event():
109
  asyncio.create_task(analyze_all_patients())
110
 
111
- async def analyze_all_patients():
112
- from analysis import analyze_patient
113
- patients = await patients_collection.find({}).to_list(length=None)
114
- for patient in patients:
115
- await analyze_patient(patient)
116
- await asyncio.sleep(0.1)
 
4
  from db.mongo import get_mongo_client
5
  import asyncio
6
  from pyfcm import FCMNotification
 
7
  from datetime import datetime
8
  import httpx
9
+ import os
10
 
11
  # Logging
12
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(name)s - %(message)s")
 
42
  notifications_collection = db["notifications"]
43
  logger.info("📡 Connected to MongoDB synchronously at %s", datetime.utcnow().isoformat())
44
 
45
+ # Retrieve secrets from environment variables (set in Hugging Face Space Secrets)
46
+ FCM_API_KEY = os.getenv("FCM_API_KEY")
47
+ SECRET_KEY = os.getenv("SECRET_KEY")
48
 
49
  if not FCM_API_KEY or not SECRET_KEY:
50
+ logger.error("❌ Missing FCM_API_KEY or SECRET_KEY in environment variables")
51
+ raise ValueError("FCM_API_KEY and SECRET_KEY must be set in Hugging Face Space Secrets")
52
 
53
  # FCM settings
54
  push_service = FCMNotification(api_key=FCM_API_KEY)
55
 
56
  # Auth Space URL
57
+ AUTH_SPACE_URL = "https://your-auth-space-name.hf.space/auth"
58
 
59
  async def send_push_notification(recipient_email, message):
60
  try:
 
108
  async def startup_event():
109
  asyncio.create_task(analyze_all_patients())
110
 
111
+ async def analyze_all_patients():