Coverage for mlos_bench/mlos_bench/services/types/remote_config_type.py: 100%
6 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6Protocol interface for configuring cloud services.
7"""
9from typing import Any, Dict, Protocol, Tuple, TYPE_CHECKING, runtime_checkable
11if TYPE_CHECKING:
12 from mlos_bench.environments.status import Status
15@runtime_checkable
16class SupportsRemoteConfig(Protocol):
17 """
18 Protocol interface for configuring cloud services.
19 """
21 def configure(self, config: Dict[str, Any],
22 params: Dict[str, Any]) -> Tuple["Status", dict]:
23 """
24 Update the parameters of a SaaS service in the cloud.
26 Parameters
27 ----------
28 config : Dict[str, Any]
29 Key/value pairs of configuration parameters (e.g., vmName).
30 params : Dict[str, Any]
31 Key/value pairs of the service parameters to update.
33 Returns
34 -------
35 result : (Status, dict={})
36 A pair of Status and result. The result is always {}.
37 Status is one of {PENDING, SUCCEEDED, FAILED}
38 """
40 def is_config_pending(self, config: Dict[str, Any]) -> Tuple["Status", dict]:
41 """
42 Check if the configuration of a service requires reboot or restart.
44 Parameters
45 ----------
46 config : Dict[str, Any]
47 Key/value pairs of configuration parameters (e.g., vmName).
49 Returns
50 -------
51 result : (Status, dict)
52 A pair of Status and result. A Boolean field
53 "isConfigPendingRestart" indicates whether the service restart is required.
54 If "isConfigPendingReboot" is set to True, rebooting a VM is necessary.
55 Status is one of {PENDING, TIMED_OUT, SUCCEEDED, FAILED}
56 """