Open luponzo86 opened 3 years ago
A quick fix would be to add the following check:
# import trajectory
u = mda.Universe(pdb_file, traj_file)
# set number of parallel processes
if n_jobs == -1:
n_jobs = len(os.sched_getaffinity(0))
# make sure that n_jobs is not greater than the actual number of frames
n_total_frames = len(u.trajectory)
n_actual_frames = len(range(
start if start else 0,
min(n_total_frames, stop) if stop else n_total_frames,
step if step else 1))
n_jobs = min(n_jobs, n_actual_frames)
Thank you.
@luponzo86 you could create a pull request with your check. We would review, guide you in adding tests, and you'd become an author of PMDA.
Development on PMDA is currently pretty slow because everybody is doing many other things (and in particular, there's a lot of work on MDAnalysis itself). Any help is greatly appreciated.
Expected behaviour
Successfully running
AnalysisFromFunction()
on all available CPUs by settingn_jobs=-1
even for very small trajectories.Actual behaviour
A Warning is raised:
but the code runs anyway until an error is thrown:
Code to reproduce the behaviour
I could not find MDs to run an example on (I had problems installing
MDAnalysisTests
, see issue #3084) but it basically happens whenAnalysisFromFunction()
is run on a trajectory withn
frames andn_jobs
is set to a value greater thann
, orn_jobs = -1
This is not a big deal, but it was hard to debug and I wanted to report it.
Currently version of MDAnalysis: 1.0.0
pmda version: 0.3.0