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

7 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-21 01:50 +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, Protocol, 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 # pylint: disable=unnecessary-ellipsis 

18 

19 def configure(self, config: dict[str, Any], params: dict[str, Any]) -> tuple["Status", dict]: 

20 """ 

21 Update the parameters of a SaaS service in the cloud. 

22 

23 Parameters 

24 ---------- 

25 config : dict[str, Any] 

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

27 params : dict[str, Any] 

28 Key/value pairs of the service parameters to update. 

29 

30 Returns 

31 ------- 

32 result : (Status, dict) 

33 A pair of Status and result. The result is always {}. 

34 Status is one of {PENDING, SUCCEEDED, FAILED} 

35 """ 

36 ... 

37 

38 def is_config_pending(self, config: dict[str, Any]) -> tuple["Status", dict]: 

39 """ 

40 Check if the configuration of a service requires reboot or restart. 

41 

42 Parameters 

43 ---------- 

44 config : dict[str, Any] 

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

46 

47 Returns 

48 ------- 

49 result : (Status, dict) 

50 A pair of Status and result. A Boolean field 

51 "isConfigPendingRestart" indicates whether the service restart is required. 

52 If "isConfigPendingReboot" is set to True, rebooting a VM is necessary. 

53 Status is one of {PENDING, TIMED_OUT, SUCCEEDED, FAILED} 

54 """ 

55 ...