Coverage for mlos_bench/mlos_bench/services/types/remote_exec_type.py: 100%
6 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-05 00:36 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-05 00:36 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6Protocol interface for Service types that provide helper functions to run
7scripts on a remote host OS.
8"""
10from typing import Iterable, Tuple, Protocol, runtime_checkable, TYPE_CHECKING
12if TYPE_CHECKING:
13 from mlos_bench.environments.status import Status
16@runtime_checkable
17class SupportsRemoteExec(Protocol):
18 """
19 Protocol interface for Service types that provide helper functions to run
20 scripts on a remote host OS.
21 """
23 def remote_exec(self, script: Iterable[str], config: dict,
24 env_params: dict) -> Tuple["Status", dict]:
25 """
26 Run a command on remote host OS.
28 Parameters
29 ----------
30 script : Iterable[str]
31 A list of lines to execute as a script on a remote VM.
32 config : dict
33 Flat dictionary of (key, value) pairs of parameters.
34 They usually come from `const_args` and `tunable_params`
35 properties of the Environment.
36 env_params : dict
37 Parameters to pass as *shell* environment variables into the script.
38 This is usually a subset of `config` with some possible conversions.
40 Returns
41 -------
42 result : (Status, dict)
43 A pair of Status and result.
44 Status is one of {PENDING, SUCCEEDED, FAILED}
45 """
47 def get_remote_exec_results(self, config: dict) -> Tuple["Status", dict]:
48 """
49 Get the results of the asynchronously running command.
51 Parameters
52 ----------
53 config : dict
54 Flat dictionary of (key, value) pairs of tunable parameters.
55 Must have the "asyncResultsUrl" key to get the results.
56 If the key is not present, return Status.PENDING.
58 Returns
59 -------
60 result : (Status, dict)
61 A pair of Status and result.
62 Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT}
63 """