Skip to content

Commit 069452b

Browse files
bpkrothmotus
andauthored
Refactor Scheduler schema definitions to make it easier to add new ones. (#979)
# Pull Request ## Title Refactor Scheduler schema definitions to make it easier to add new ones. ______________________________________________________________________ ## Description Simple refactor of the Scheduler schemas to allow making new ones as a copy/edit of the `synchscheduler-subschema.json`. ______________________________________________________________________ ## Type of Change - 🔄 Refactor ______________________________________________________________________ ## Testing - Exisiting CI checks for good and bad scheduler config files still pass. - Adding additional tests to actually load those configs with `mlos_bench` next. ______________________________________________________________________ ## Additional Notes (optional) - Splitting some new testing infra out from #973. - Adding `MockScheduler` next, then `ParallelScheduler` in #971. ______________________________________________________________________ --------- Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
1 parent c6b2a54 commit 069452b

File tree

3 files changed

+107
-92
lines changed

3 files changed

+107
-92
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/schedulers/base-scheduler-subschema.json",
4+
"title": "mlos_bench base Scheduler config schema definitions",
5+
"description": "mlos_bench base Scheduler config schema definitions for all Scheduler types.",
6+
7+
"$defs": {
8+
"base_scheduler_config": {
9+
"$comment": "config properties common to all Scheduler types.",
10+
"description": "The scheduler-specific config.",
11+
"type": "object",
12+
"minProperties": 1,
13+
"properties": {
14+
"experiment_id": {
15+
"$ref": "../cli/common-defs-subschemas.json#/$defs/experiment_id"
16+
},
17+
"trial_id": {
18+
"$ref": "../cli/common-defs-subschemas.json#/$defs/trial_id"
19+
},
20+
"config_id": {
21+
"$ref": "../cli/common-defs-subschemas.json#/$defs/config_id"
22+
},
23+
"teardown": {
24+
"description": "Whether to teardown the experiment after running it.",
25+
"type": "boolean"
26+
},
27+
"max_trials": {
28+
"description": "Max. number of trials to run. Use -1 or 0 for unlimited.",
29+
"type": "integer",
30+
"minimum": -1,
31+
"examples": [50, -1]
32+
},
33+
"trial_config_repeat_count": {
34+
"description": "Number of times to repeat a config.",
35+
"type": "integer",
36+
"minimum": 1,
37+
"examples": [3, 5]
38+
}
39+
}
40+
}
41+
},
42+
43+
"type": "object",
44+
"properties": {
45+
"$schema": {
46+
"description": "The schema to use for validating the scheduler config (accepts both URLs and local paths).",
47+
"type": "string",
48+
"$comment": "This is optional, but if provided, should match the name of the root schema file.",
49+
"pattern": "/schemas/schedulers/scheduler-schema.json$"
50+
},
51+
52+
"description": {
53+
"description": "Optional description of the config.",
54+
"type": "string"
55+
},
56+
57+
"class": {
58+
"description": "The name of the scheduler class to use.",
59+
"type": "string",
60+
"$comment": "Exact matches are handled elsewhere.",
61+
"pattern": "^mlos_bench[.]schedulers[.]"
62+
},
63+
64+
"config": {
65+
"$ref": "#/$defs/base_scheduler_config"
66+
}
67+
},
68+
"required": ["class"]
69+
}

mlos_bench/mlos_bench/config/schemas/schedulers/scheduler-schema.json

Lines changed: 11 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,105 +2,24 @@
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"$id": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/schedulers/scheduler-schema.json",
44
"title": "mlos_bench Scheduler config",
5-
6-
"$defs": {
7-
"comment": {
8-
"$comment": "This section contains reusable partial schema bits (or just split out for readability)"
9-
},
10-
11-
"config_base_scheduler": {
12-
"$comment": "config properties common to all Scheduler types.",
13-
"type": "object",
14-
"properties": {
15-
"experiment_id": {
16-
"$ref": "../cli/common-defs-subschemas.json#/$defs/experiment_id"
17-
},
18-
"trial_id": {
19-
"$ref": "../cli/common-defs-subschemas.json#/$defs/trial_id"
20-
},
21-
"config_id": {
22-
"$ref": "../cli/common-defs-subschemas.json#/$defs/config_id"
23-
},
24-
"teardown": {
25-
"description": "Whether to teardown the experiment after running it.",
26-
"type": "boolean"
27-
},
28-
"max_trials": {
29-
"description": "Max. number of trials to run. Use -1 or 0 for unlimited.",
30-
"type": "integer",
31-
"minimum": -1,
32-
"examples": [50, -1]
33-
},
34-
"trial_config_repeat_count": {
35-
"description": "Number of times to repeat a config.",
36-
"type": "integer",
37-
"minimum": 1,
38-
"examples": [3, 5]
39-
}
40-
}
41-
}
42-
},
43-
445
"description": "config for the mlos_bench scheduler",
456
"$comment": "top level schema document rules",
46-
"type": "object",
47-
"properties": {
48-
"$schema": {
49-
"description": "The schema to use for validating the scheduler config (accepts both URLs and local paths).",
50-
"type": "string",
51-
"$comment": "This is optional, but if provided, should match the name of this file.",
52-
"pattern": "/schemas/schedulers/scheduler-schema.json$"
53-
},
54-
55-
"description": {
56-
"description": "Optional description of the config.",
57-
"type": "string"
58-
},
597

60-
"class": {
61-
"description": "The name of the scheduler class to use.",
62-
"$comment": "required",
63-
"enum": [
64-
"mlos_bench.schedulers.SyncScheduler",
65-
"mlos_bench.schedulers.sync_scheduler.SyncScheduler"
66-
]
8+
"type": "object",
9+
"allOf": [
10+
{
11+
"$comment": "All scheduler subschemas support these base properties.",
12+
"$ref": "./base-scheduler-subschema.json"
6713
},
68-
69-
"config": {
70-
"description": "The scheduler-specific config.",
71-
"$comment": "Stub for scheduler-specific config appended with condition statements below",
72-
"type": "object",
73-
"minProperties": 1
74-
}
75-
},
76-
"required": ["class"],
77-
78-
"oneOf": [
7914
{
80-
"$comment": "extensions to the 'config' object properties when synchronous scheduler is being used",
81-
"if": {
82-
"properties": {
83-
"class": {
84-
"enum": [
85-
"mlos_bench.schedulers.SyncScheduler",
86-
"mlos_bench.schedulers.sync_scheduler.SyncScheduler"
87-
]
88-
}
89-
},
90-
"required": ["class"]
91-
},
92-
"then": {
93-
"properties": {
94-
"config": {
95-
"type": "object",
96-
"allOf": [{ "$ref": "#/$defs/config_base_scheduler" }],
97-
"$comment": "disallow other properties",
98-
"unevaluatedProperties": false
99-
}
15+
"$comment": "The set of known Scheduler subschemas. Add others as needed.",
16+
"oneOf": [
17+
{
18+
"$ref": "./sync-scheduler-subschema.json"
10019
}
101-
},
102-
"else": false
20+
]
10321
}
10422
],
23+
"required": ["class"],
10524
"unevaluatedProperties": false
10625
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/schedulers/sync-scheduler-subschema.json",
4+
"title": "mlos_bench SyncScheduler config",
5+
"description": "config for an mlos_bench SyncScheduler",
6+
"type": "object",
7+
"properties": {
8+
"class": {
9+
"enum": [
10+
"mlos_bench.schedulers.SyncScheduler",
11+
"mlos_bench.schedulers.sync_scheduler.SyncScheduler"
12+
]
13+
},
14+
"config": {
15+
"type": "object",
16+
"$comment": "No extra properties supported by SyncScheduler.",
17+
"allOf": [
18+
{
19+
"$ref": "base-scheduler-subschema.json#/$defs/base_scheduler_config"
20+
}
21+
],
22+
"minProperties": 1,
23+
"unevaluatedProperties": false
24+
}
25+
},
26+
"required": ["class"]
27+
}

0 commit comments

Comments
 (0)