Spaces:
Building
Building
Update config_provider.py
Browse files- config_provider.py +16 -4
config_provider.py
CHANGED
@@ -1,7 +1,19 @@
|
|
1 |
-
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def get_config():
|
7 |
-
return
|
|
|
1 |
+
import json
|
2 |
+
from pathlib import Path
|
3 |
+
from fastapi import Depends
|
4 |
|
5 |
+
CONFIG_FILE = Path("service_config.json")
|
6 |
+
|
7 |
+
class ServiceConfig:
|
8 |
+
def __init__(self):
|
9 |
+
with open(CONFIG_FILE, "r") as f:
|
10 |
+
self.data = json.load(f)
|
11 |
+
|
12 |
+
def get_current_project(self):
|
13 |
+
if not self.data['projects']:
|
14 |
+
raise ValueError("No projects configured")
|
15 |
+
# For simplicity, just return the first project
|
16 |
+
return self.data['projects'][0]
|
17 |
|
18 |
def get_config():
|
19 |
+
return ServiceConfig()
|