pylbo.automation.runner
Classes
Handles running legolas. |
Functions
|
Validates the given executable, then returns it. If the argument passed is |
|
Validates the number of cpus passed to the multiprocessing pool. |
|
Validates a list of parfiles. |
Module Contents
- pylbo.automation.runner._validate_executable(executable)
Validates the given executable, then returns it. If the argument passed is None, defaults to the executable in the legolas home directory.
- Parameters:
executable (str, PathLike) – The path to the legolas executable to use.
- Raises:
FileNotFoundError – If the executable was not found.
- Returns:
executable – The (resolved) path to the executable to use.
- Return type:
- pylbo.automation.runner._validate_nb_cpus(cpus)
Validates the number of cpus passed to the multiprocessing pool. Defaults to the maximum available number if exceeded.
- pylbo.automation.runner._validate_parfiles(files)
Validates a list of parfiles.
- Parameters:
files ((list of) str, (list of) PathLike) – Paths to the parfiles.
- Raises:
FileNotFoundError – If one of the parfiles is not found.
- Returns:
files_list – A list of resolved filepaths for the parfiles.
- Return type:
- class pylbo.automation.runner.LegolasRunner(parfiles, remove_parfiles, nb_cpus, executable=None)
Handles running legolas.
- Parameters:
parfiles (list, numpy.ndarray) – A list or array containing the names or paths to the parfiles.
remove_parfiles (bool) – If True, removes the parfiles after running Legolas. This will also remove the containing folder if it turns out to be empty after the parfiles are removed. If there are other files still in the folder it remains untouched.
nb_cpus (int) – The number of CPUs to use when running Legolas. If equal to 1 then parallelisation is disabled. Defaults to the maximum number of CPUs available if a number larger than the available number is specified.
executable (str, PathLike) – The path to the legolas executable.
- parfiles
- parfile_dir
- executable
- nb_cpus
- remove_parfiles
- static _init_worker()
Worker initialisation for the multiprocessing module.
- _activate_worker(parfile)
Worker activation for the multiprocessing module. Calls the legolas executable as a subprocess with the parfile as argument.
- Parameters:
- Returns:
call – A call to a subprocess to run legolas.
- Return type:
- static _terminate_workers()
Terminates the multiprocessing workers after a forced interruption. Simply giving an interrupt terminates only the Python processes, but still keeps the Legolas calls running since those are subprocesses. This method first terminates all child processes (legolas), then the parents (workers).
- execute()
Executes the legolas executables and initialises the multiprocessing pool if requested.