pylfi.utils.check_and_set_jobs

pylfi.utils.check_and_set_jobs(n_jobs, logger=None)[source]

Check and set passed number of jobs.

Checks whether passed n_jobs has correct type and value, raises if not.

If n_jobs exceeds the number of available CPUs found by Pathos (this might include hardware threads), n_jobs is set to the number found by Pathos.

If n_jobs=-1, then n_jobs is set to half of the CPUs found by Pathos (we assume half of the CPUs are only hardware threads and ignore those).

Parameters
n_jobsint

Number of processes (workers) passed by user.

loggerlogging.Logger

Logger object.

Returns
n_jobsint

Possibly corrected number of processes (workers).