Coverage for mlos_bench/mlos_bench/tests/services/remote/mock/mock_remote_exec_service.py: 100%
7 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""A collection Service functions for mocking remote script execution."""
7from typing import Any, Callable, Dict, List, Optional, Union
9from mlos_bench.services.base_service import Service
10from mlos_bench.services.types.remote_exec_type import SupportsRemoteExec
11from mlos_bench.tests.services.remote.mock import mock_operation
14class MockRemoteExecService(Service, SupportsRemoteExec):
15 """Mock remote script execution service."""
17 def __init__(
18 self,
19 config: Optional[Dict[str, Any]] = None,
20 global_config: Optional[Dict[str, Any]] = None,
21 parent: Optional[Service] = None,
22 methods: Union[Dict[str, Callable], List[Callable], None] = None,
23 ):
24 """
25 Create a new instance of mock remote exec service.
27 Parameters
28 ----------
29 config : dict
30 Free-format dictionary that contains the benchmark environment
31 configuration.
32 global_config : dict
33 Free-format dictionary of global parameters.
34 parent : Service
35 Parent service that can provide mixin functions.
36 """
37 super().__init__(
38 config,
39 global_config,
40 parent,
41 self.merge_methods(
42 methods,
43 {
44 "remote_exec": mock_operation,
45 "get_remote_exec_results": mock_operation,
46 },
47 ),
48 )