Coverage for mlos_bench/mlos_bench/services/types/remote_config_type.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-07 01:52 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5"""Protocol interface for configuring cloud services.""" 

6 

7from typing import TYPE_CHECKING, Any, Dict, Protocol, Tuple, runtime_checkable 

8 

9if TYPE_CHECKING: 

10 from mlos_bench.environments.status import Status 

11 

12 

13@runtime_checkable 

14class SupportsRemoteConfig(Protocol): 

15 """Protocol interface for configuring cloud services.""" 

16 

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. 

20 

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. 

27 

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 """ 

34 

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. 

38 

39 Parameters 

40 ---------- 

41 config : Dict[str, Any] 

42 Key/value pairs of configuration parameters (e.g., vmName). 

43 

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 """