1
1
""" app's configuration
2
2
3
+ This module loads the schema defined by every subsystem and injects it in the
4
+ application's configuration scheams
5
+
6
+ It was designed in a similar fashion to the setup protocol of the application
7
+ where every subsystem is imported and queried in a specific order. The application
8
+ depends on the subsystem and not the other way around.
9
+
10
+ The app configuration is created before the application instance exists.
11
+
3
12
4
13
TODO: add more strict checks with re
5
14
TODO: add support for versioning.
6
15
- check shema fits version
7
16
- parse/format version in schema
8
- TODO add simcore_sdk.config.s3 section!!!
9
- TODO: create decorator so every module injects sections in a global schema. This way we avoid cyclic dependencies
17
+ TODO: add simcore_sdk.config.s3 section!!!
10
18
"""
11
19
import logging
12
20
21
29
log = logging .getLogger (__name__ )
22
30
23
31
32
+
33
+
24
34
def create_schema ():
25
35
"""
26
36
Build schema for the configuration's file
@@ -33,7 +43,7 @@ def create_schema():
33
43
"port" : T .Int (),
34
44
T .Key ("public_url" , optional = True ): T .Or (T .String (), T .List (T .String )), # full url seen by front-end
35
45
"client_outdir" : T .String (),
36
- "log_level" : T .Enum ( list ( logging ._nameToLevel .keys ()) ) , # pylint: disable=W0212
46
+ "log_level" : T .Enum (* logging ._nameToLevel .keys ()), # pylint: disable=protected-access
37
47
"testing" : T .Bool (),
38
48
T .Key ("disable_services" , default = [], optional = True ): T .List (T .String ()), # TODO: optional enable function in every section
39
49
}),
@@ -46,7 +56,7 @@ def create_schema():
46
56
47
57
48
58
section_names = [k .name for k in schema .keys ]
49
- assert len (section_names ) == set (section_names ), "Found repeated section names in %s" % section_names
59
+ assert len (section_names ) == len ( set (section_names ) ), "Found repeated section names in %s" % section_names
50
60
51
61
return schema
52
62
0 commit comments