Coverage for mlos_bench/mlos_bench/services/types/os_ops_type.py: 100%
7 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
« 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 Host/OS operations.
7"""
9from typing import Tuple, Protocol, runtime_checkable, TYPE_CHECKING
11if TYPE_CHECKING:
12 from mlos_bench.environments.status import Status
15@runtime_checkable
16class SupportsOSOps(Protocol):
17 """
18 Protocol interface for Host/OS operations.
19 """
21 def shutdown(self, params: dict, force: bool = False) -> Tuple["Status", dict]:
22 """
23 Initiates a (graceful) shutdown of the Host/VM OS.
25 Parameters
26 ----------
27 params: dict
28 Flat dictionary of (key, value) pairs of tunable parameters.
29 force : bool
30 If True, force stop the Host/VM.
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 """
39 def reboot(self, params: dict, force: bool = False) -> Tuple["Status", dict]:
40 """
41 Initiates a (graceful) shutdown of the Host/VM OS.
43 Parameters
44 ----------
45 params: dict
46 Flat dictionary of (key, value) pairs of tunable parameters.
47 force : bool
48 If True, force restart the Host/VM.
50 Returns
51 -------
52 result : (Status, dict={})
53 A pair of Status and result. The result is always {}.
54 Status is one of {PENDING, SUCCEEDED, FAILED}
55 """
57 def wait_os_operation(self, params: dict) -> Tuple["Status", dict]:
58 """
59 Waits for a pending operation on an OS to resolve to SUCCEEDED or FAILED.
60 Return TIMED_OUT when timing out.
62 Parameters
63 ----------
64 params: dict
65 Flat dictionary of (key, value) pairs of tunable parameters.
66 Must have the "asyncResultsUrl" key to get the results.
67 If the key is not present, return Status.PENDING.
69 Returns
70 -------
71 result : (Status, dict)
72 A pair of Status and result.
73 Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT}
74 Result is info on the operation runtime if SUCCEEDED, otherwise {}.
75 """