Add extra check in fix_job_kwargs#2829
Conversation
| @@ -87,9 +87,14 @@ def fix_job_kwargs(runtime_job_kwargs): | |||
| n_jobs = job_kwargs["n_jobs"] | |||
| assert isinstance(n_jobs, (float, np.integer, int)) | |||
| if isinstance(n_jobs, float): | |||
There was a problem hiding this comment.
| if isinstance(n_jobs, float): | |
| if isinstance(n_jobs, float) and n_jobs <= 1: |
@zm711 maybe this is better?
There was a problem hiding this comment.
we would need to add another:
else:
n_jobs = int(n_jobs)
There was a problem hiding this comment.
So flip the if-else so the more common path is triggered first?
if isinstance(n_jobs, float) and n_jobs <= 1:
int(n_jobs * os.cpu_counts())
else:
int(n_jobs)There was a problem hiding this comment.
I see you're saying fuse all into if-elif-else!
There was a problem hiding this comment.
Let me know what you think of this!
|
I personally think that we should raise an error if someone sets 0 jobs rather than fix it for them.... Should I change that test or revert raising the error? |
The old behavior was to set |
For functions that take in an
n_jobsargument they all runfix_job_kwargs, but if the user gives something like 4.0 to mean 4 jobs they end up with (if they have 4 cores)int(4.0 * 4.0) = 16
So instead we should cast 4.0 -> 4 and just make it 4 jobs no?
What do you think @alejoe91 ?