Coverage for sparkle/types/sparkle_callable.py: 88%
17 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
1"""Abstract class Sparkle Callable."""
2from __future__ import annotations
3from pathlib import Path
6class SparkleCallable:
7 """Sparkle Callable class."""
9 def __init__(self: SparkleCallable,
10 directory: Path,
11 runsolver_exec: Path = None,
12 raw_output_directory: Path = None) -> None:
13 """Initialize callable.
15 Args:
16 directory: Directory of the callable.
17 runsolver_exec: Path to the runsolver executable.
18 By default, runsolver in solver_directory.
19 raw_output_directory: Directory where callable will write its raw output.
20 Defaults to directory / tmp
21 """
22 self.directory = directory
23 self.name = directory.name
24 self.raw_output_directory = raw_output_directory
25 self.runsolver_exec = runsolver_exec
26 if self.raw_output_directory is None:
27 self.raw_output_directory = self.directory / "tmp"
28 self.raw_output_directory.mkdir(exist_ok=True)
29 if self.runsolver_exec is None:
30 self.runsolver_exec = self.directory / "runsolver"
32 def build_cmd(self: SparkleCallable) -> list[str | Path]:
33 """A method that builds the commandline call string."""
34 return NotImplementedError
36 def run(self: SparkleCallable) -> None:
37 """A method that runs the callable."""
38 return NotImplementedError