Skip to content

Commit e7bc888

Browse files
committed
enable all tests in test_resource_monitor
1 parent 4e85b75 commit e7bc888

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

nipype/interfaces/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def load_template(name):
101101
template : string.Template
102102
103103
"""
104-
105104
full_fname = os.path.join(os.path.dirname(__file__),
106105
'script_templates', name)
107106
template_file = open(full_fname)

nipype/interfaces/tests/test_resource_monitor.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
#!/usr/bin/env python
12
# -*- coding: utf-8 -*-
2-
# test_profiler.py
3-
#
4-
# Author: Daniel Clark, 2016
5-
3+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4+
# vi: set ft=python sts=4 ts=4 sw=4 et:
65
"""
76
Module to unit test the resource_monitor in nipype
87
"""
@@ -17,19 +16,17 @@
1716
from nipype.interfaces import utility as niu
1817

1918

20-
# UseResources inputspec
2119
class UseResourcesInputSpec(CommandLineInputSpec):
2220
mem_gb = traits.Float(desc='Number of GB of RAM to use',
2321
argstr='-g %f', mandatory=True)
2422
n_procs = traits.Int(desc='Number of threads to use',
2523
argstr='-p %d', mandatory=True)
2624

2725

28-
# UseResources interface
2926
class UseResources(CommandLine):
30-
'''
27+
"""
3128
use_resources cmd interface
32-
'''
29+
"""
3330
from nipype import __path__
3431
# Init attributes
3532
input_spec = UseResourcesInputSpec
@@ -48,10 +45,10 @@ class UseResources(CommandLine):
4845
@pytest.mark.skipif(run_profile is False, reason='resources monitor is disabled')
4946
@pytest.mark.parametrize("mem_gb,n_procs", [(0.5, 3), (2.2, 8), (0.8, 4), (1.5, 1)])
5047
def test_cmdline_profiling(tmpdir, mem_gb, n_procs):
51-
'''
48+
"""
5249
Test runtime profiler correctly records workflow RAM/CPUs consumption
5350
of a CommandLine-derived interface
54-
'''
51+
"""
5552
from nipype import config
5653
config.set('execution', 'resource_monitor_frequency', '0.2') # Force sampling fast
5754

@@ -67,10 +64,10 @@ def test_cmdline_profiling(tmpdir, mem_gb, n_procs):
6764
@pytest.mark.skipif(run_profile is False, reason='resources monitor is disabled')
6865
@pytest.mark.parametrize("mem_gb,n_procs", [(0.5, 3), (2.2, 8), (0.8, 4), (1.5, 1)])
6966
def test_function_profiling(tmpdir, mem_gb, n_procs):
70-
'''
67+
"""
7168
Test runtime profiler correctly records workflow RAM/CPUs consumption
7269
of a Function interface
73-
'''
70+
"""
7471
from nipype import config
7572
config.set('execution', 'resource_monitor_frequency', '0.2') # Force sampling fast
7673

@@ -80,5 +77,5 @@ def test_function_profiling(tmpdir, mem_gb, n_procs):
8077
iface.inputs.n_procs = n_procs
8178
result = iface.run()
8279

83-
# assert abs(mem_gb - result.runtime.mem_peak_gb) < 0.3, 'estimated memory error above .3GB'
80+
assert abs(mem_gb - result.runtime.mem_peak_gb) < 0.3, 'estimated memory error above .3GB'
8481
assert int(result.runtime.cpu_percent / 100 + 0.2) >= n_procs

nipype/utils/profiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ def _use_gb_ram(mem_gb):
358358
_use_cpu(5)
359359
mem_total = p.memory_info().rss / _GB
360360
del big_str
361-
iflogger.info('[%d] Memory offset %0.2fGB, total %0.2fGB', os.getpid(), mem_offset, mem_total)
361+
iflogger.info('[%d] Memory offset %0.2fGB, total %0.2fGB',
362+
os.getpid(), mem_offset, mem_total)
362363

363364
if n_procs > 1:
364365
pool = Pool(n_procs)

0 commit comments

Comments
 (0)