Skip to content

Commit 3f5e97f

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1128 from vkarak/feat/config-json-schema
[feat] Introduce new configuration syntax and validation schema
2 parents 2f3cfcb + e421390 commit 3f5e97f

File tree

3 files changed

+545
-0
lines changed

3 files changed

+545
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
jsonschema
12
pytest>=3.5.0
23
coverage
34
setuptools

schemas/config.json

Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://raw.githubusercontent.com/eth-cscs/reframe/master/schemas/config.json",
4+
"title": "Validation schema for ReFrame's configuration file",
5+
"defs": {
6+
"alphanum_string": {
7+
"type": "string",
8+
"pattern": "([a-zA-Z0-9_]|-)+"
9+
},
10+
"system_ref": {
11+
"type": "array",
12+
"items": {"type": "string"}
13+
},
14+
"envvar_list": {
15+
"type": "array",
16+
"items": {
17+
"type": "array",
18+
"items": [
19+
{
20+
"type": "string",
21+
"pattern": "([a-zA-Z_][a-zA-Z0-9_]*)"
22+
},
23+
{"type": "string"}
24+
],
25+
"additionalProperties": false
26+
}
27+
},
28+
"modules_list": {
29+
"type": "array",
30+
"items": {"type": "string"}
31+
},
32+
"loglevel": {
33+
"type": "string",
34+
"enum": ["critical", "error", "warning",
35+
"info", "verbose", "debug"]
36+
},
37+
"handler_common": {
38+
"type": "object",
39+
"properties": {
40+
"type": {"type": "string"},
41+
"level": {"$ref": "#/defs/loglevel"},
42+
"format": {"type": "string"},
43+
"datefmt": {"type": "string"}
44+
},
45+
"required": ["type"]
46+
},
47+
"file_handler": {
48+
"allOf": [
49+
{"$ref": "#/defs/handler_common"},
50+
{
51+
"properties": {
52+
"name": {"type": "string"},
53+
"append": {"type": "boolean"},
54+
"timestamp": {
55+
"anyOf": [
56+
{"type": "boolean"},
57+
{"type": "string"}
58+
]
59+
}
60+
},
61+
"required": ["name"]
62+
}
63+
]
64+
},
65+
"filelog_handler": {
66+
"allOf": [
67+
{"$ref": "#/defs/handler_common"},
68+
{
69+
"properties": {
70+
"prefix": {"type": "string"}
71+
}
72+
}
73+
]
74+
},
75+
"graylog_handler": {
76+
"allOf": [
77+
{"$ref": "#/defs/handler_common"},
78+
{
79+
"properties": {
80+
"address": {"type": "string"},
81+
"extras": {"type": "object"}
82+
},
83+
"required": ["address"]
84+
}
85+
]
86+
},
87+
"stream_handler": {
88+
"allOf": [
89+
{"$ref": "#/defs/handler_common"},
90+
{
91+
"properties": {
92+
"name": {
93+
"type": "string",
94+
"enum": ["stdout", "stderr"]
95+
}
96+
}
97+
}
98+
]
99+
},
100+
"syslog_handler": {
101+
"allOf": [
102+
{"$ref": "#/defs/handler_common"},
103+
{
104+
"properties": {
105+
"socktype": {
106+
"type": "string",
107+
"enum": ["tcp", "udp"]
108+
},
109+
"facility": {"type": "string"},
110+
"address": {"type": "string"}
111+
},
112+
"required": ["address"]
113+
}
114+
]
115+
}
116+
},
117+
"type": "object",
118+
"properties": {
119+
"systems": {
120+
"type": "array",
121+
"items": {
122+
"type": "object",
123+
"properties": {
124+
"name": {"$ref": "#/defs/alphanum_string"},
125+
"descr": {"type": "string"},
126+
"hostnames": {
127+
"type": "array",
128+
"items": {"type": "string"}
129+
},
130+
"modules_system": {
131+
"type": "string",
132+
"enum": ["tmod", "tmod31", "tmod32", "tmod4", "lmod"]
133+
},
134+
"modules": {"$ref": "#/defs/modules_list"},
135+
"variables": {"$ref": "#/defs/envvar_list"},
136+
"prefix": {"type": "string"},
137+
"stagedir": {"type": "string"},
138+
"outputdir": {"type": "string"},
139+
"perflogdir": {"type": "string"},
140+
"resourcesdir": {"type": "string"},
141+
"partitions": {
142+
"type": "array",
143+
"items": {
144+
"type": "object",
145+
"properties": {
146+
"name": {"$ref": "#/defs/alphanum_string"},
147+
"descr": {"type": "string"},
148+
"scheduler": {
149+
"type": "string",
150+
"enum": ["local", "pbs", "slurm", "squeue"]
151+
},
152+
"launcher": {
153+
"type": "string",
154+
"enum": [
155+
"alps", "ibrun", "local", "mpirun",
156+
"mpiexec", "srun", "srunalloc", "ssh"
157+
]
158+
},
159+
"access": {
160+
"type": "array",
161+
"items": {"type": "string"}
162+
},
163+
"environs": {
164+
"type": "array",
165+
"items": {"type": "string"}
166+
},
167+
"container_platforms": {
168+
"type": "array",
169+
"items": {
170+
"type": "object",
171+
"properties": {
172+
"name": {
173+
"type": "string",
174+
"enum": ["Docker", "Sarus",
175+
"Singularity"]
176+
},
177+
"modules": {
178+
"$ref": "#/defs/modules_list"
179+
},
180+
"variables": {
181+
"$ref": "#/defs/envvar_list"
182+
}
183+
},
184+
"required": ["name"]
185+
}
186+
},
187+
"modules": {"$ref": "#/defs/modules_list"},
188+
"variables": {"$ref": "#/defs/envvar_list"},
189+
"max_jobs": {"type": "number"},
190+
"resources": {
191+
"type": "array",
192+
"items": {
193+
"type": "object",
194+
"properties": {
195+
"name": {"type": "string"},
196+
"options": {
197+
"type": "array",
198+
"items": {"type": "string"}
199+
},
200+
"additionalProperties": false
201+
}
202+
}
203+
}
204+
},
205+
"required": ["name", "scheduler", "launcher"],
206+
"additionalProperties": false
207+
}
208+
}
209+
},
210+
"required": ["name"],
211+
"additionalProperties": false
212+
}
213+
},
214+
"environments": {
215+
"type": "array",
216+
"items": {
217+
"type": "object",
218+
"properties": {
219+
"name": {"type": "string"},
220+
"modules": {"$ref": "#/defs/modules_list"},
221+
"variables": {"$ref": "#/defs/envvar_list"},
222+
"cc": {"type": "string"},
223+
"cxx": {"type": "string"},
224+
"ftn": {"type": "string"},
225+
"cppflags": {
226+
"type": "array",
227+
"items": {"type": "string"}
228+
},
229+
"cflags": {
230+
"type": "array",
231+
"items": {"type": "string"}
232+
},
233+
"cxxflags": {
234+
"type": "array",
235+
"items": {"type": "string"}
236+
},
237+
"fflags": {
238+
"type": "array",
239+
"items": {"type": "string"}
240+
},
241+
"ldflags": {
242+
"type": "array",
243+
"items": {"type": "string"}
244+
},
245+
"target_systems": {"$ref": "#/defs/system_ref"}
246+
},
247+
"required": ["name"],
248+
"additionalProperties": false
249+
}
250+
},
251+
"schedulers": {
252+
"type": "array",
253+
"items": {
254+
"type": "object",
255+
"properties": {
256+
"name": {"type": "string"},
257+
"job_submit_timeout": {"type": "number"},
258+
"target_systems": {"$ref": "#/defs/system_ref"}
259+
},
260+
"required": ["name"],
261+
"additionalProperties": false
262+
}
263+
},
264+
"logging": {
265+
"type": "array",
266+
"items": {
267+
"type": "object",
268+
"properties": {
269+
"level": {"$ref": "#/defs/loglevel"},
270+
"handlers": {
271+
"type": "array",
272+
"items": {
273+
"anyOf": [
274+
{"$ref": "#/defs/file_handler"},
275+
{"$ref": "#/defs/filelog_handler"},
276+
{"$ref": "#/defs/graylog_handler"},
277+
{"$ref": "#/defs/stream_handler"},
278+
{"$ref": "#/defs/syslog_handler"}
279+
]
280+
}
281+
},
282+
"target_systems": {"$ref": "#/defs/system_ref"}
283+
},
284+
"additionalProperties": false
285+
}
286+
},
287+
"perf_logging": {
288+
"type": "array",
289+
"items": {
290+
"type": "object",
291+
"properties": {
292+
"level": {"$ref": "#/defs/loglevel"},
293+
"handlers": {
294+
"type": "array",
295+
"items": {
296+
"anyOf": [
297+
{"$ref": "#/defs/file_handler"},
298+
{"$ref": "#/defs/filelog_handler"},
299+
{"$ref": "#/defs/graylog_handler"},
300+
{"$ref": "#/defs/stream_handler"},
301+
{"$ref": "#/defs/syslog_handler"}
302+
]
303+
}
304+
},
305+
"target_systems": {"$ref": "#/defs/system_ref"}
306+
},
307+
"additionalProperties": false
308+
}
309+
},
310+
"modes": {
311+
"type": "array",
312+
"items": {
313+
"type": "object",
314+
"properties": {
315+
"name": {"type": "string"},
316+
"options": {
317+
"type": "array",
318+
"items": {"type": "string"}
319+
},
320+
"target_systems": {"$ref": "#/defs/system_ref"}
321+
},
322+
"required": ["name"],
323+
"additionalProperties": false
324+
}
325+
},
326+
"general": {
327+
"type": "array",
328+
"items": {
329+
"type": "object",
330+
"properties": {
331+
"check_search_path": {
332+
"type": "array",
333+
"items": {"type": "string"}
334+
},
335+
"check_search_recursive": {"type": "boolean"},
336+
"target_systems": {"$ref": "#/defs/system_ref"}
337+
},
338+
"additionalProperties": false
339+
}
340+
}
341+
},
342+
"required": ["systems", "environments", "logging", "perf_logging"],
343+
"additionalProperties": false,
344+
"defaults": {
345+
"environments/cc": "cc",
346+
"environments/cxx": "CC",
347+
"environments/ftn": "ftn",
348+
"environments/target_systems": ["*"],
349+
"general/check_search_path": ["checks/"],
350+
"general/check_search_recursive": "true",
351+
"general/target_systems": ["*"],
352+
"perf_logging/target_systems": ["*"],
353+
"logging/handlers/level": "DEBUG",
354+
"logging/handlers/file/append": false,
355+
"logging/handlers/file/timestamp": false,
356+
"logging/handlers/stream/name": "stdout",
357+
"logging/handlers/syslog/socktype": "udp",
358+
"logging/handlers/syslog/facility": "user",
359+
"logging/level": "INFO",
360+
"logging/target_systems": ["*"],
361+
"modes/target_systems": ["*"],
362+
"schedulers/job_submit_timeout": 60,
363+
"schedulers/target_systems": ["*"],
364+
"systems/prefix": ".",
365+
"systems/resourcesdir": "."
366+
}
367+
}

0 commit comments

Comments
 (0)