mlos_bench.services.local package

Local scheduler side Services for mlos_bench.

class mlos_bench.services.local.LocalExecService(config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None, methods: Dict[str, Callable] | List[Callable] | None = None)

Bases: TempDirContextService, SupportsLocalExec

Collection of methods to run scripts and commands in an external process on the node acting as the scheduler.

Can be useful for data processing due to reduced dependency management complications vs the target environment.

Attributes:
config_loader_service

Return a config loader service.

Methods

export()

Return a dictionary of functions available in this service.

local_exec(script_lines[, env, cwd])

Execute the script lines from script_lines in a local process.

merge_methods(ext_methods, local_methods)

Merge methods from the external caller with the local ones.

new(class_name[, config, global_config, parent])

Factory method for a new service with a given config.

pprint()

Produce a human-readable string listing all public methods of the service.

register(services)

Register new mix-in services.

temp_dir_context([path])

Create a temp directory or use the provided path.

local_exec(script_lines: Iterable[str], env: Mapping[str, TunableValue] | None = None, cwd: str | None = None) Tuple[int, str, str]

Execute the script lines from script_lines in a local process.

Parameters:
script_linesIterable[str]

Lines of the script to run locally. Treat every line as a separate command to run.

envMapping[str, Union[int, float, str]]

Environment variables (optional).

cwdstr

Work directory to run the script at. If omitted, use temp_dir or create a temporary dir.

Returns:
(return_code, stdout, stderr)(int, str, str)

A 3-tuple of return code, stdout, and stderr of the script process.

Submodules