-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
77 lines (67 loc) · 2.61 KB
/
config.py
File metadata and controls
77 lines (67 loc) · 2.61 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
from functools import lru_cache
from pydantic import AliasChoices, Field
from pydantic_settings import BaseSettings
@lru_cache()
def get_settings():
return Settings()
class Settings(BaseSettings):
auth0_domain: str = ""
auth0_api_audience: str = ""
auth0_issuer: str = ""
auth0_algorithms: str = "RS256"
auth0_client_id: str = ""
auth0_client_secret: str = ""
database_url: str = ""
auth_secret: str = ""
auth_trust_host: bool = False
# Accept the historical OCF_* env var names in addition to the canonical
# OTELA_* ones so existing deployments keep working through the rename.
# Python attribute access stays `settings.otela_*`.
otela_head_addr: str = Field(
default="",
validation_alias=AliasChoices("otela_head_addr", "ocf_head_addr"),
)
# When set, /v1/models* reads this JSON file instead of calling
# $otela_head_addr/v1/dnt/table. Used for UI iteration against synthesised
# upgraded payloads (see backend/tests/fixtures/build_upgraded.py).
otela_fixture_path: str = Field(
default="",
validation_alias=AliasChoices("otela_fixture_path", "ocf_fixture_path"),
)
# CSCS L1 passthrough — when set, chat/completion requests for the
# hardcoded L1 model list in backend/services/cscs_l1_service.py are
# forwarded here instead of the OpenTela network. Lets us expose
# Apertus 8B/70B from the upstream L1 service without launching our
# own k8s pods. Both must be provided via env in k8s secrets.
cscs_l1_base_url: str = ""
cscs_l1_api_key: str = ""
langfuse_host: str = ""
langfuse_public_key: str = ""
langfuse_secret_key: str = ""
vite_auth0_client_id: str = ""
vite_auth0_domain: str = ""
firebase_service_account_json: str = ""
access_log: bool = False
class Config:
env_file = ".env"
populate_by_name = True
def parse_hardware_info(hardware_info):
"""
Parse hardware information and return a string representation.
Args:
hardware_info (dict): Dictionary containing hardware information
Returns:
str: String representation of the hardware in the format "Nx[Spec]"
"""
if not hardware_info or "gpus" not in hardware_info or not hardware_info["gpus"]:
return "Unknown"
# Group GPUs by name
gpu_counts = {}
for gpu in hardware_info["gpus"]:
name = gpu.get("name", "Unknown GPU")
gpu_counts[name] = gpu_counts.get(name, 0) + 1
# Format the output
result = []
for gpu_name, count in gpu_counts.items():
result.append(f"{count}x {gpu_name}")
return ", ".join(result)