Coverage for src/sparkle/tools/runsolver/resolver.py: 100%
9 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-15 14:11 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-15 14:11 +0000
1"""Resolver class if RunSolver is not supported."""
3from pathlib import Path
5from sparkle.tools.runsolver.runsolver import RunSolver
6from sparkle.tools.runsolver.py_runsolver import PyRunSolver
9class RunSolverResolver(RunSolver):
10 """Class representation the RunSolver Resolver."""
12 @staticmethod
13 def wrap_command(
14 runsolver_executable: Path,
15 command: list[str],
16 cutoff_time: int,
17 log_directory: Path,
18 log_name_base: str = None,
19 raw_results_file: bool = True,
20 ) -> list[str]:
21 """Resolves if RunSolver is available. Otherwise uses a python implementation.
23 Args:
24 runsolver_executable: The Path to the runsolver executable.
25 Is returned as an *absolute* path in the output.
26 command: The command to wrap.
27 cutoff_time: The cutoff CPU time for the solver.
28 log_directory: The directory where to write the solver output.
29 log_name_base: A user defined name to easily identify the logs.
30 Defaults to "runsolver".
31 raw_results_file: Whether to use the raw results file.
33 Returns:
34 List of commands and arguments to execute the solver.
35 """
36 if runsolver_executable.exists():
37 return RunSolver.wrap_command(
38 runsolver_executable,
39 command,
40 cutoff_time,
41 log_directory,
42 log_name_base,
43 raw_results_file,
44 )
45 else:
46 return PyRunSolver.wrap_command(
47 command, cutoff_time, log_directory, log_name_base, raw_results_file
48 )