Skip to content

Commit 5f917f2

Browse files
committed
fix: final touches to the PR
Close #2944. Close #2949.
1 parent 829957c commit 5f917f2

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

nipype/caching/tests/test_memory.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class SideEffectInterface(EngineTestInterface):
1515
def _run_interface(self, runtime):
1616
global nb_runs
1717
nb_runs += 1
18-
runtime.returncode = 0
19-
return runtime
18+
return super(SideEffectInterface, self)._run_interface(runtime)
2019

2120

2221
def test_caching(tmpdir):

nipype/pipeline/engine/tests/test_base.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@ class OutputSpec(nib.TraitedSpec):
2020
output1 = nib.traits.List(nib.traits.Int, desc='outputs')
2121

2222

23-
class EngineTestInterface(nib.BaseInterface):
23+
class EngineTestInterface(nib.SimpleInterface):
2424
input_spec = InputSpec
2525
output_spec = OutputSpec
2626

2727
def _run_interface(self, runtime):
2828
runtime.returncode = 0
29+
self._results['output1'] = [1, self.inputs.input1]
2930
return runtime
3031

31-
def _list_outputs(self):
32-
outputs = self._outputs().get()
33-
outputs['output1'] = [1, self.inputs.input1]
34-
return outputs
35-
3632

3733
@pytest.mark.parametrize(
3834
'name', ['valid1', 'valid_node', 'valid-node', 'ValidNode0'])

nipype/pipeline/engine/utils.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@
4141
)
4242
from ...utils.misc import str2bool
4343
from ...utils.functions import create_function_from_source
44-
from ...interfaces.base.traits_extension import rebase_path_traits, resolve_path_traits
45-
from ...interfaces.base import (Bunch, CommandLine, isdefined, Undefined,
46-
InterfaceResult, traits)
44+
from ...interfaces.base.traits_extension import (
45+
rebase_path_traits, resolve_path_traits, OutputMultiPath, isdefined, Undefined, traits)
46+
from ...interfaces.base.support import Bunch, InterfaceResult
47+
from ...interfaces.base import CommandLine
4748
from ...interfaces.utility import IdentityInterface
4849
from ...utils.provenance import ProvStore, pm, nipype_ns, get_id
4950

@@ -239,7 +240,7 @@ def save_resultfile(result, cwd, name, rebase=True):
239240
savepkl(resultsfile, result)
240241
return
241242
try:
242-
outputs = result.outputs.trait_get()
243+
output_names = result.outputs.copyable_trait_names()
243244
except AttributeError:
244245
logger.debug('Storing non-traited results, skipping rebase of paths')
245246
savepkl(resultsfile, result)
@@ -249,9 +250,12 @@ def save_resultfile(result, cwd, name, rebase=True):
249250
try:
250251
with indirectory(cwd):
251252
# All the magic to fix #2944 resides here:
252-
for key, old in list(outputs.items()):
253+
for key in output_names:
254+
old = getattr(result.outputs, key)
253255
if isdefined(old):
254-
old = result.outputs.trait(key).handler.get_value(result.outputs, key)
256+
if result.outputs.trait(key).is_trait_type(OutputMultiPath):
257+
old = result.outputs.trait(key).handler.get_value(
258+
result.outputs, key)
255259
backup_traits[key] = old
256260
val = rebase_path_traits(result.outputs.trait(key), old, cwd)
257261
setattr(result.outputs, key, val)
@@ -310,8 +314,9 @@ def load_resultfile(results_file, resolve=True):
310314
logger.debug('Resolving paths in outputs loaded from results file.')
311315
for trait_name, old in list(outputs.items()):
312316
if isdefined(old):
313-
old = result.outputs.trait(trait_name).handler.get_value(
314-
result.outputs, trait_name)
317+
if result.outputs.trait(trait_name).is_trait_type(OutputMultiPath):
318+
old = result.outputs.trait(trait_name).handler.get_value(
319+
result.outputs, trait_name)
315320
value = resolve_path_traits(result.outputs.trait(trait_name), old,
316321
results_file.parent)
317322
setattr(result.outputs, trait_name, value)

0 commit comments

Comments
 (0)