Execution Constraints
The execution constraints class is used to define the constraints on the execution of a black box. The execution constraints requires an enforcer. The current supported enforcer is RunSolver.
- class optilog.blackbox.ExecutionConstraints(enforcer, h_wall_time=None, h_cpu_time=None, h_virtual_memory=None, h_real_memory=None, s_wall_time=None, s_cpu_time=None, s_virtual_memory=None, s_real_memory=None)
Describes the execution constraints of a process
- Parameters
h_wall_time (
Optional
[int
]) – Hard Wall time limit in secondss_wall_time (
Optional
[int
]) – Soft Wall time limit in secondsh_cpu_time (
Optional
[int
]) – Hard CPU time limit in secondss_cpu_time (
Optional
[int
]) – Soft CPU time limit in secondsh_virtual_memory (
Optional
[str
]) – Hard virtual memory limit in secondss_virtual_memory (
Optional
[str
]) – Soft virtual memory limit in secondsh_real_memory (
Optional
[str
]) – Hard real memory limit (rss+swap) in secondss_real_memory (
Optional
[str
]) – Soft real memory limit (rss+swap) in secondsenforcer (
Enforcer
) – Enforcer object that ensures the execution constraints are respected.
- class optilog.blackbox.RunSolver(path=None, delay=None, watcher_path=None, timestamp=False)
RunSolver class that implements the Enforcer interface and ensures the execution constraints are satisfied.
Warning
Note that RunSolver is a separate program not included with OptiLog. You can download it from http://www.cril.univ-artois.fr/~roussel/runsolver/
RunSolver actively monitors the full tree of processes spawned by the command and kills them if the constraints are not respected. In order to do so, the process will wake up routinely and check the constraints.
This may cause a slight overhead in cache misses and context switches. A way to reduce this overhead is to reseve an extra core for the runsolver process.
You can only set the soft constraints on RunSolver because the hard constraints are enforced after
delay
seconds are passed.- Parameters
path (
Optional
[Path
]) – Path to the runsolver executable. If None, the path will be searched in the PATH environment variable.delay (
Optional
[int
]) – Delay in seconds between checking the constraints. If None, the default value of runsolver will be used.watcher_path (
Union
[str
,Path
,None
]) – Path to the watcher file. If None, a temporary file will be created.timestamp (
bool
) – If True, the data will have the wall time and cpu time attached to it, also stdout and stderr will be merged into stdout.
Example with RunSolver and no extra parameters:
1RunningScenario(
2 tasks=tasks,
3 solvers=solvers_dict,
4 submit_file=f"submitter.sh",
5 constraints=ExecutionConstraints(
6 s_wall_time=1000,
7 s_real_memory="100M",
8 enforcer=RunSolver()
9 ))
- class optilog.blackbox.DockerEnforcer
DockerEnforcer class that implements the Enforcer interface and ensures the execution constraints are satisfied. This class uses Docker to enforce the execution constraints.