DomLoyer commited on
Commit
3aaebd6
·
1 Parent(s): ca696b3

update: syscred/config.py

Browse files
Files changed (1) hide show
  1. syscred/config.py +11 -8
syscred/config.py CHANGED
@@ -23,17 +23,19 @@ from pathlib import Path
23
  from typing import Dict, Optional
24
  from dotenv import load_dotenv
25
 
26
- # Charger les variables depuis .env
27
  # Charger les variables depuis .env (Project Root)
28
- # Path: .../systemFactChecking/02_Code/syscred/config.py
29
- # Root .env is at .../systemFactChecking/.env (3 levels up)
30
  current_path = Path(__file__).resolve()
31
- env_path = current_path.parent.parent.parent / '.env'
32
 
33
  if not env_path.exists():
34
  print(f"[Config] WARNING: .env not found at {env_path}")
35
- # Try alternate location (sometimes CWD matters)
36
- env_path = Path.cwd().parent / '.env'
 
 
 
37
 
38
  load_dotenv(dotenv_path=env_path)
39
  print(f"[Config] Loading .env from {env_path}")
@@ -50,8 +52,9 @@ class Config:
50
  """
51
 
52
  # === Chemins ===
 
53
  BASE_DIR = Path(__file__).parent.parent
54
- ONTOLOGY_BASE_PATH = BASE_DIR / "sysCRED_onto26avrtil.ttl"
55
  ONTOLOGY_DATA_PATH = BASE_DIR / "ontology" / "sysCRED_data.ttl"
56
 
57
  # === Serveur Flask ===
@@ -61,7 +64,7 @@ class Config:
61
 
62
  # === API Keys ===
63
  GOOGLE_FACT_CHECK_API_KEY = os.getenv("SYSCRED_GOOGLE_API_KEY")
64
- DATABASE_URL = os.getenv("DATABASE_URL") # [NEW] Read DB URL from env
65
 
66
  # === Modèles ML ===
67
  # Support both SYSCRED_LOAD_ML and SYSCRED_LOAD_ML_MODELS (for Render)
 
23
  from typing import Dict, Optional
24
  from dotenv import load_dotenv
25
 
 
26
  # Charger les variables depuis .env (Project Root)
27
+ # Path: .../systemFactChecking/syscred/config.py
28
+ # Root .env is at .../systemFactChecking/.env (1 level up from syscred/)
29
  current_path = Path(__file__).resolve()
30
+ env_path = current_path.parent.parent / '.env'
31
 
32
  if not env_path.exists():
33
  print(f"[Config] WARNING: .env not found at {env_path}")
34
+ # Try alternate locations
35
+ for alt in [Path.cwd() / '.env', Path.cwd().parent / '.env']:
36
+ if alt.exists():
37
+ env_path = alt
38
+ break
39
 
40
  load_dotenv(dotenv_path=env_path)
41
  print(f"[Config] Loading .env from {env_path}")
 
52
  """
53
 
54
  # === Chemins ===
55
+ # BASE_DIR = project root (parent of syscred/)
56
  BASE_DIR = Path(__file__).parent.parent
57
+ ONTOLOGY_BASE_PATH = BASE_DIR / "ontology" / "sysCRED_onto26avrtil.ttl"
58
  ONTOLOGY_DATA_PATH = BASE_DIR / "ontology" / "sysCRED_data.ttl"
59
 
60
  # === Serveur Flask ===
 
64
 
65
  # === API Keys ===
66
  GOOGLE_FACT_CHECK_API_KEY = os.getenv("SYSCRED_GOOGLE_API_KEY")
67
+ DATABASE_URL = os.getenv("SYSCRED_DATABASE_URL", os.getenv("DATABASE_URL")) # Standardized env var
68
 
69
  # === Modèles ML ===
70
  # Support both SYSCRED_LOAD_ML and SYSCRED_LOAD_ML_MODELS (for Render)