Coverage for mlos_bench/mlos_bench/services/types/host_provisioner_type.py: 100%
7 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Protocol interface for Host/VM provisioning operations."""
7from typing import TYPE_CHECKING, Protocol, Tuple, runtime_checkable
9if TYPE_CHECKING:
10 from mlos_bench.environments.status import Status
13@runtime_checkable
14class SupportsHostProvisioning(Protocol):
15 """Protocol interface for Host/VM provisioning operations."""
17 def provision_host(self, params: dict) -> Tuple["Status", dict]:
18 """
19 Check if Host/VM is ready. Deploy a new Host/VM, if necessary.
21 Parameters
22 ----------
23 params : dict
24 Flat dictionary of (key, value) pairs of tunable parameters.
25 VMEnv tunables are variable parameters that, together with the
26 VMEnv configuration, are sufficient to provision a VM.
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 wait_host_deployment(self, params: dict, *, is_setup: bool) -> Tuple["Status", dict]:
36 """
37 Waits for a pending operation on a Host/VM to resolve to SUCCEEDED or FAILED.
38 Return TIMED_OUT when timing out.
40 Parameters
41 ----------
42 params : dict
43 Flat dictionary of (key, value) pairs of tunable parameters.
44 is_setup : bool
45 If True, wait for Host/VM being deployed; otherwise, wait for successful
46 deprovisioning.
48 Returns
49 -------
50 result : (Status, dict)
51 A pair of Status and result.
52 Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT}
53 Result is info on the operation runtime if SUCCEEDED, otherwise {}.
54 """
56 def deprovision_host(self, params: dict) -> Tuple["Status", dict]:
57 """
58 Deprovisions the Host/VM by deleting it.
60 Parameters
61 ----------
62 params : dict
63 Flat dictionary of (key, value) pairs of tunable parameters.
65 Returns
66 -------
67 result : (Status, dict)
68 A pair of Status and result. The result is always {}.
69 Status is one of {PENDING, SUCCEEDED, FAILED}
70 """
72 def deallocate_host(self, params: dict) -> Tuple["Status", dict]:
73 """
74 Deallocates the Host/VM by shutting it down then releasing the compute
75 resources.
77 Note: This can cause the VM to arrive on a new host node when its
78 restarted, which may have different performance characteristics.
80 Parameters
81 ----------
82 params : dict
83 Flat dictionary of (key, value) pairs of tunable parameters.
85 Returns
86 -------
87 result : (Status, dict)
88 A pair of Status and result. The result is always {}.
89 Status is one of {PENDING, SUCCEEDED, FAILED}
90 """