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

7 statements  

« 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 Network provisioning operations. 

7""" 

8 

9from typing import Tuple, Protocol, runtime_checkable, TYPE_CHECKING 

10 

11if TYPE_CHECKING: 

12 from mlos_bench.environments.status import Status 

13 

14 

15@runtime_checkable 

16class SupportsNetworkProvisioning(Protocol): 

17 """ 

18 Protocol interface for Network provisioning operations. 

19 """ 

20 

21 def provision_network(self, params: dict) -> Tuple["Status", dict]: 

22 """ 

23 Check if Network is ready. Deploy a new Network, if necessary. 

24 

25 Parameters 

26 ---------- 

27 params : dict 

28 Flat dictionary of (key, value) pairs of tunable parameters. 

29 NetworkEnv tunables are variable parameters that, together with the 

30 NetworkEnv configuration, are sufficient to provision a NetworkEnv. 

31 

32 Returns 

33 ------- 

34 result : (Status, dict={}) 

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

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

37 """ 

38 

39 def wait_network_deployment(self, params: dict, *, is_setup: bool) -> Tuple["Status", dict]: 

40 """ 

41 Waits for a pending operation on a Network to resolve to SUCCEEDED or FAILED. 

42 Return TIMED_OUT when timing out. 

43 

44 Parameters 

45 ---------- 

46 params : dict 

47 Flat dictionary of (key, value) pairs of tunable parameters. 

48 is_setup : bool 

49 If True, wait for Network being deployed; otherwise, wait for successful deprovisioning. 

50 

51 Returns 

52 ------- 

53 result : (Status, dict) 

54 A pair of Status and result. 

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

56 Result is info on the operation runtime if SUCCEEDED, otherwise {}. 

57 """ 

58 

59 def deprovision_network(self, params: dict, ignore_errors: bool = True) -> Tuple["Status", dict]: 

60 """ 

61 Deprovisions the Network by deleting it. 

62 

63 Parameters 

64 ---------- 

65 params : dict 

66 Flat dictionary of (key, value) pairs of tunable parameters. 

67 ignore_errors : boolean 

68 Whether to ignore errors (default) encountered during the operation 

69 (e.g., due to dependent resources still in use). 

70 

71 Returns 

72 ------- 

73 result : (Status, dict={}) 

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

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

76 """