Skip to content

Commit

Permalink
Don't require empty config element in service json schemas (microsoft…
Browse files Browse the repository at this point in the history
…#518)

Adjusts service schema's to not require an empty `"config": {}` element,
and instead only include it if there's some other property in it.

Split out from microsoft#510
  • Loading branch information
bpkroth authored Sep 28, 2023
1 parent 848c5a9 commit 6629e88
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def pytest_configure(config: pytest.Config) -> None: # pylint: disable=unused-
import matplotlib # pylint: disable=import-outside-toplevel
matplotlib.rcParams['backend'] = 'agg'
warn(UserWarning('DISPLAY environment variable is set, which can cause problems in some setups (e.g. WSL). '
+ f'Adjusting matplotlib backend to "{matplotlib.rcParams["backend"]}" to compensate.'))
+ f'Adjusting matplotlib backend to "{matplotlib.rcParams["backend"]}" to compensate.'))
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
"unevaluatedProperties": false
}
},
"required": ["class", "config"]
"required": ["class"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"type": "object",
"properties": {},
"required": [],
"minProperties": 1,
"unevaluatedProperties": false
}
},
"required": ["class", "config"]
"required": ["class"]
}
78 changes: 43 additions & 35 deletions mlos_bench/mlos_bench/config/schemas/services/service-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,52 @@
"service_config": {
"type": "object",
"$comment": "additional service types should be added here",
"oneOf": [
{
"$ref": "./local/local-exec-service-subschema.json"
},
{
"$ref": "./local/temp-dir-context-service-subschema.json"
},
{
"$ref": "./local/mock/mock-local-exec-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-fileshare-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-vm-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-remote-exec-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-auth-service-subschema.json"
},
{
"$ref": "./remote/azure/azure-auth-service-subschema.json"
},
"allOf": [
{
"$ref": "./remote/azure/azure-vm-service-subschema.json"
"oneOf": [
{
"$ref": "./local/local-exec-service-subschema.json"
},
{
"$ref": "./local/temp-dir-context-service-subschema.json"
},
{
"$ref": "./local/mock/mock-local-exec-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-fileshare-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-vm-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-remote-exec-service-subschema.json"
},
{
"$ref": "./remote/mock/mock-auth-service-subschema.json"
},
{
"$ref": "./remote/azure/azure-auth-service-subschema.json"
},
{
"$ref": "./remote/azure/azure-vm-service-subschema.json"
},
{
"$ref": "./remote/azure/azure-fileshare-service-subschema.json"
}
],
"required": ["class"]
},
{
"$ref": "./remote/azure/azure-fileshare-service-subschema.json"
"type": "object",
"properties": {
"config": {
"type": "object",
"$comment": "Service-specific config.",
"minProperties": 1
}
}
}
],
"required": [
"class",
"config"
]
},
"top_level_items": {
Expand Down Expand Up @@ -72,10 +83,7 @@
"$ref": "#/$defs/service_config"
}
],
"required": [
"class",
"config"
]
"required": ["class"]
},
{
"$comment": "We no longer accept a flat list of Service objects.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"class": "mlos_bench.services.remote.azure.AzureAuthService"
"class": "mlos_bench.services.remote.azure.AzureAuthService",
"config": {
// should be omitted if empty
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"class": "mlos_bench.services.remote.azure.AzureAuthService",
"config": {}
"class": "mlos_bench.services.remote.azure.AzureAuthService"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"class": "mlos_bench.tests.services.remote.mock.mock_auth_service.MockAuthService",
"config": {}
"class": "mlos_bench.tests.services.remote.mock.mock_auth_service.MockAuthService"
}

0 comments on commit 6629e88

Please sign in to comment.