-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconfig.py
More file actions
78 lines (59 loc) · 2.08 KB
/
config.py
File metadata and controls
78 lines (59 loc) · 2.08 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
78
import settings
import yaml
_config: dict = None
def get_config() -> dict:
"""This is to keep logic of accessing config in one place"""
global _config
with open(settings.CONSERVER_CONFIG_FILE) as file:
_config = yaml.safe_load(file) or {}
return _config
def get_worker_count() -> int:
"""Get the number of worker processes to spawn.
Returns:
int: Number of workers (minimum 1)
"""
return max(1, settings.CONSERVER_WORKERS)
def is_parallel_storage_enabled() -> bool:
"""Check if parallel storage writes are enabled.
Returns:
bool: True if parallel storage is enabled
"""
return settings.CONSERVER_PARALLEL_STORAGE
def get_start_method() -> str | None:
"""Get the multiprocessing start method.
Returns:
str | None: "fork", "spawn", "forkserver", or None for platform default
"""
method = settings.CONSERVER_START_METHOD
if method and method not in ("fork", "spawn", "forkserver"):
raise ValueError(
f"Invalid CONSERVER_START_METHOD: {method}. "
"Must be 'fork', 'spawn', 'forkserver', or empty for default."
)
return method
class Configuration:
@classmethod
def get_config(cls) -> dict:
return get_config()
@classmethod
def get_storages(cls) -> dict:
config = cls.get_config()
return config.get("storages", {})
@classmethod
def get_followers(cls) -> dict:
config = cls.get_config()
return config.get("followers", {})
@classmethod
def get_imports(cls) -> dict:
config = cls.get_config()
return config.get("imports", {})
@classmethod
def get_ingress_auth(cls) -> dict:
"""Get ingress-specific API key configuration.
Returns:
dict: Dictionary mapping ingress list names to their API keys.
Values can be either a single string (one API key) or
a list of strings (multiple API keys for the same ingress list).
"""
config = cls.get_config()
return config.get("ingress_auth", {})