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