Coverage for src / sparkle / types / sparkle_callable.py: 83%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-21 15:31 +0000

1"""Abstract class Sparkle Callable.""" 

2 

3from __future__ import annotations 

4from pathlib import Path 

5 

6 

7class SparkleCallable: 

8 """Sparkle Callable class.""" 

9 

10 def __init__( 

11 self: SparkleCallable, directory: Path, runsolver_exec: Path = None 

12 ) -> None: 

13 """Initialize callable. 

14 

15 Args: 

16 directory: Directory of the callable. 

17 runsolver_exec: Path to the runsolver executable. 

18 By default, runsolver in solver_directory. 

19 """ 

20 self.directory = directory 

21 self.name = directory.name 

22 self._runsolver_exec = runsolver_exec 

23 

24 def __hash__(self) -> int: 

25 """Hash callable based on the directory.""" 

26 return self.directory.__hash__() 

27 

28 @property 

29 def runsolver_exec(self: SparkleCallable) -> Path: 

30 """Return the path of the runsolver executable.""" 

31 if self._runsolver_exec is None: 

32 return self.directory / "runsolver" 

33 return self._runsolver_exec 

34 

35 def build_cmd(self: SparkleCallable) -> list[str | Path]: 

36 """A method that builds the commandline call string.""" 

37 return NotImplementedError 

38 

39 def run(self: SparkleCallable) -> None: 

40 """A method that runs the callable.""" 

41 return NotImplementedError