-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
103 lines (80 loc) · 3.39 KB
/
settings.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import json
import os
with open("default.json", "r") as file:
SOCIAL_DISTANCING_DEFAULT_VALUES = json.loads(file.read())
SOCIAL_DISTANCING_VAR_POPULATION = int(os.environ.get(
key="SOCIAL_DISTANCING_VAR_POPULATION",
default=SOCIAL_DISTANCING_DEFAULT_VALUES["population"]
))
SOCIAL_DISTANCING_TAG_STRATEGY_INTERACTING = "social-interacting"
SOCIAL_DISTANCING_TAG_STRATEGY_DISTANCING = "social-distancing"
SOCIAL_DISTANCING_VAR_STRATEGIES = [
SOCIAL_DISTANCING_TAG_STRATEGY_INTERACTING,
SOCIAL_DISTANCING_TAG_STRATEGY_DISTANCING
]
SOCIAL_DISTANCING_VAR_STRATEGY = os.environ.get(
key="SOCIAL_DISTANCING_VAR_STRATEGY",
default=SOCIAL_DISTANCING_DEFAULT_VALUES["strategy"]
)
if SOCIAL_DISTANCING_VAR_STRATEGY not in SOCIAL_DISTANCING_VAR_STRATEGIES:
raise ValueError(f"Undefined strategy: {SOCIAL_DISTANCING_VAR_STRATEGY}")
SOCIAL_DISTANCING_DEFAULT_STRATEGY_VALUES = SOCIAL_DISTANCING_DEFAULT_VALUES.get("scenarios", {}).get(
SOCIAL_DISTANCING_VAR_STRATEGY,
{}
)
SOCIAL_DISTANCING_DEFAULT_PEOPLE_DISTRIBUTION_VALUES = SOCIAL_DISTANCING_DEFAULT_STRATEGY_VALUES.get(
"people-distribution",
{}
)
# STUDENTS
SOCIAL_DISTANCING_VAR_PERCENT_STUDENTS = int(os.environ.get(
key="SOCIAL_DISTANCING_VAR_PERCENT_STUDENTS",
default=SOCIAL_DISTANCING_DEFAULT_PEOPLE_DISTRIBUTION_VALUES["students"]
))
SOCIAL_DISTANCING_VAR_STUDENTS = round(SOCIAL_DISTANCING_VAR_PERCENT_STUDENTS * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# WORKERS
SOCIAL_DISTANCING_VAR_PERCENT_WORKERS = int(os.environ.get(
key="SOCIAL_DISTANCING_VAR_PERCENT_WORKERS",
default=SOCIAL_DISTANCING_DEFAULT_PEOPLE_DISTRIBUTION_VALUES["workers"]
))
SOCIAL_DISTANCING_VAR_WORKERS = round(SOCIAL_DISTANCING_VAR_PERCENT_WORKERS * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# WORKER STUDENTS
SOCIAL_DISTANCING_VAR_PERCENT_WORKER_STUDENTS = int(os.environ.get(
key="SOCIAL_DISTANCING_VAR_PERCENT_WORKER_STUDENTS",
default=SOCIAL_DISTANCING_DEFAULT_PEOPLE_DISTRIBUTION_VALUES["worker-students"]
))
SOCIAL_DISTANCING_VAR_WORKER_STUDENTS = round(
SOCIAL_DISTANCING_VAR_PERCENT_WORKER_STUDENTS * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# STAY HOME
SOCIAL_DISTANCING_VAR_PERCENT_STAY_HOME = int(os.environ.get(
key="SOCIAL_DISTANCING_VAR_PERCENT_STAY_HOME",
default=SOCIAL_DISTANCING_DEFAULT_PEOPLE_DISTRIBUTION_VALUES["stay-home"]
))
SOCIAL_DISTANCING_VAR_STAY_HOME = \
round(SOCIAL_DISTANCING_VAR_PERCENT_STAY_HOME * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# NUM HOMES
SOCIAL_DISTANCING_VAR_FACTORY_NUM_HOMES = round(float(os.environ.get(
key="SOCIAL_DISTANCING_VAR_FACTORY_NUM_HOMES",
default="20"
)) * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# NUM WORKPLACE
SOCIAL_DISTANCING_VAR_FACTORY_NUM_WORKPLACE = round(float(os.environ.get(
key="SOCIAL_DISTANCING_VAR_FACTORY_NUM_WORKPLACE",
default="10"
)) * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# NUM UNIVERSITY
SOCIAL_DISTANCING_VAR_FACTORY_NUM_UNIVERSITY = round(float(os.environ.get(
key="SOCIAL_DISTANCING_VAR_FACTORY_NUM_UNIVERSITY",
default="1"
)) * SOCIAL_DISTANCING_VAR_POPULATION / 100)
# NUM PUBLIC
SOCIAL_DISTANCING_VAR_FACTORY_NUM_PUBLIC = round(float(os.environ.get(
key="SOCIAL_DISTANCING_VAR_FACTORY_NUM_PUBLIC",
default="15"
)) * SOCIAL_DISTANCING_VAR_POPULATION / 100)
def get_global_environment_vars(prefix="SOCIAL_DISTANCING"):
return {
k: v
for k, v in globals().items()
if k.startswith(prefix)
}