Coverage for mlos_bench/mlos_bench/services/types/host_provisioner_type.py: 64%
11 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-21 01:50 +0000
« 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 Host/VM provisioning operations."""
7from typing import TYPE_CHECKING, Protocol, 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 # pylint: disable=unnecessary-ellipsis
19 def provision_host(self, params: dict) -> tuple["Status", dict]:
20 """
21 Check if Host/VM is ready. Deploy a new Host/VM, if necessary.
23 Parameters
24 ----------
25 params : dict
26 Flat dictionary of (key, value) pairs of tunable parameters.
27 VMEnv tunables are variable parameters that, together with the
28 VMEnv configuration, are sufficient to provision a VM.
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 ...
38 def wait_host_deployment(self, params: dict, *, is_setup: bool) -> tuple["Status", dict]:
39 """
40 Waits for a pending operation on a Host/VM to resolve to SUCCEEDED or FAILED.
41 Return TIMED_OUT when timing out.
43 Parameters
44 ----------
45 params : dict
46 Flat dictionary of (key, value) pairs of tunable parameters.
47 is_setup : bool
48 If True, wait for Host/VM being deployed; otherwise, wait for successful
49 deprovisioning.
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 ...
60 def deprovision_host(self, params: dict) -> tuple["Status", dict]:
61 """
62 Deprovisions the Host/VM by deleting it.
64 Parameters
65 ----------
66 params : dict
67 Flat dictionary of (key, value) pairs of tunable parameters.
69 Returns
70 -------
71 result : (Status, dict)
72 A pair of Status and result. The result is always {}.
73 Status is one of {PENDING, SUCCEEDED, FAILED}
74 """
75 ...
77 def deallocate_host(self, params: dict) -> tuple["Status", dict]:
78 """
79 Deallocates the Host/VM by shutting it down then releasing the compute
80 resources.
82 Note: This can cause the VM to arrive on a new host node when its
83 restarted, which may have different performance characteristics.
85 Parameters
86 ----------
87 params : dict
88 Flat dictionary of (key, value) pairs of tunable parameters.
90 Returns
91 -------
92 result : (Status, dict)
93 A pair of Status and result. The result is always {}.
94 Status is one of {PENDING, SUCCEEDED, FAILED}
95 """
96 ...