AshenH commited on
Commit
6e7ce87
·
verified ·
1 Parent(s): aed2def

Update utils/config.py

Browse files
Files changed (1) hide show
  1. utils/config.py +34 -21
utils/config.py CHANGED
@@ -1,21 +1,34 @@
1
- import os
2
- from dataclasses import dataclass
3
-
4
- @dataclass
5
- class AppConfig:
6
- hf_model_repo: str
7
- sql_backend: str # "bigquery" or "motherduck"
8
- gcp_project: str | None = None
9
- motherduck_db: str | None = None
10
- motherduck_token: str | None = None
11
-
12
-
13
- @classmethod
14
- def from_env(cls):
15
- return cls(
16
- hf_model_repo=os.getenv("HF_MODEL_REPO", "your-username/your-private-tabular-model"),
17
- sql_backend=os.getenv("SQL_BACKEND", "motherduck"),
18
- gcp_project=os.getenv("GCP_PROJECT"),
19
- motherduck_db=os.getenv("MOTHERDUCK_DB", "default"),
20
- motherduck_token=os.getenv("MOTHERDUCK_TOKEN")
21
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dataclasses import dataclass
3
+
4
+ @dataclass
5
+ class AppConfig:
6
+ """
7
+ Central configuration class for the Tabular Agentic XAI app.
8
+ It reads all required environment variables for both BigQuery
9
+ and MotherDuck backends.
10
+ """
11
+ # Common
12
+ hf_model_repo: str
13
+ sql_backend: str # "bigquery" or "motherduck"
14
+
15
+ # BigQuery
16
+ gcp_project: str | None = None
17
+
18
+ # MotherDuck
19
+ motherduck_db: str | None = None
20
+ motherduck_token: str | None = None
21
+
22
+ @classmethod
23
+ def from_env(cls):
24
+ """
25
+ Reads environment variables from .env (local) or Hugging Face Space Secrets.
26
+ Returns an AppConfig instance.
27
+ """
28
+ return cls(
29
+ hf_model_repo=os.getenv("HF_MODEL_REPO", "your-username/your-private-tabular-model"),
30
+ sql_backend=os.getenv("SQL_BACKEND", "motherduck"),
31
+ gcp_project=os.getenv("GCP_PROJECT"),
32
+ motherduck_db=os.getenv("MOTHERDUCK_DB", "default"),
33
+ motherduck_token=os.getenv("MOTHERDUCK_TOKEN")
34
+ )