I have a task, which I aim to parallelize with the help of the joblib-library. The function is fairly slow when ran sequentially, therefore I tried using parallelization paradigms to speed up the process.
with Parallel(n_jobs = -1,verbose = 100) as parallel:
test = parallel(delayed(create_time_series_capacity_v4)(block_info.UnitID[i]) for i in block_info.UnitID.unique())
out_data = pd.concat([out_data,test[test.columns[1]]],axis=1 )
The block unique has approximately 1000 entries and the creation of the timeseries, takes longer for some units compared to others. Which leaves me to think, that some workers are left working while others are performing an intensive task. Is there a way for to reuse the available processes rather than leaving them idling ? I have pasted below what the code returns while being executed:
UNIT05-001 has been written
UNIT04-001 has been written
UNIT05-003 has been written
[Parallel(n_jobs=-1)]: Done 1 tasks | elapsed: 0.2s
[Parallel(n_jobs=-1)]: Done 2 out of 10 | elapsed: 0.2s remaining: 1.2s
[Parallel(n_jobs=-1)]: Done 3 out of 10 | elapsed: 0.2s remaining: 0.7s
UNIT05-004 has been written
[Parallel(n_jobs=-1)]: Done 4 out of 10 | elapsed: 0.4s remaining: 0.7s
UNIT05-002 has been written
[Parallel(n_jobs=-1)]: Done 5 out of 10 | elapsed: 0.6s remaining: 0.6s
UNIT02-001 has been written
[Parallel(n_jobs=-1)]: Done 6 out of 10 | elapsed: 27.9s remaining: 18.5s
UNIT01-001 has been written
[Parallel(n_jobs=-1)]: Done 7 out of 10 | elapsed: 50.4s remaining: 21.5s