Skip to content

[ENH] Migrating resource handler to Node level #1942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nipype/interfaces/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ def __init__(self, from_file=None, **inputs):
self.__class__.__name__)

self.inputs = self.input_spec(**inputs)
self.estimated_memory_gb = 1
self.estimated_memory_gb = 0.25
self.num_threads = 1

if from_file is not None:
Expand Down
8 changes: 7 additions & 1 deletion nipype/pipeline/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class Node(EngineBase):

def __init__(self, interface, name, iterables=None, itersource=None,
synchronize=False, overwrite=None, needed_outputs=None,
run_without_submitting=False, **kwargs):
run_without_submitting=False, n_procs=1, mem_gb=None,
**kwargs):
"""
Parameters
----------
Expand Down Expand Up @@ -168,6 +169,11 @@ def __init__(self, interface, name, iterables=None, itersource=None,
self.input_source = {}
self.needed_outputs = []
self.plugin_args = {}

self._interface.num_threads = n_procs
if mem_gb is not None:
self._interface.estimated_memory_gb = mem_gb

if needed_outputs:
self.needed_outputs = sorted(needed_outputs)
self._got_inputs = False
Expand Down
11 changes: 6 additions & 5 deletions nipype/pipeline/plugins/multiproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
busy_processors += self.procs[jobid]._interface.num_threads

else:
raise ValueError("Resources required by jobid %d (%f GB, %d threads)"
"exceed what is available on the system (%f GB, %d threads)"%(jobid,
self.procs[jobid].__interface.estimated_memory_gb,
self.procs[jobid].__interface.num_threads,
self.memory_gb,self.processors))
raise ValueError(
"Resources required by jobid {0} ({3}GB, {4} threads) exceed what is "
"available on the system ({1}GB, {2} threads)".format(
jobid, self.memory_gb, self.processors,
self.procs[jobid]._interface.estimated_memory_gb,
self.procs[jobid]._interface.num_threads))

free_memory_gb = self.memory_gb - busy_memory_gb
free_processors = self.processors - busy_processors
Expand Down