Repository: nipype/pydra-nipype1 (language: python)

Issue:
Process isolation does not work directly
If you use a Nipype 1 interface that requires `copyfiles`, `Nipype1Task` doesn't do this as `Node` used to. I think the solution is just to change `self._interface.run()` to `Node(self._interface).run()`.


Discussion / hints:
cc @jw-96 @neurorepro

Fix patch:
diff --git a/pydra/tasks/nipype1/utils.py b/pydra/tasks/nipype1/utils.py
index c5fbb60..5fdfc43 100644
--- a/pydra/tasks/nipype1/utils.py
+++ b/pydra/tasks/nipype1/utils.py
@@ -68,5 +68,7 @@ def __init__(
 
     def _run_task(self):
         inputs = attr.asdict(self.inputs, filter=lambda a, v: v is not attr.NOTHING)
-        res = self._interface.run(**inputs)
+        node = nipype.Node(self._interface, base_dir=self.output_dir, name=self.name)
+        node.inputs.trait_set(**inputs)
+        res = node.run()
         self.output_ = res.outputs.get()


Test patch:
diff --git a/pydra/tasks/nipype1/tests/__init__.py b/pydra/tasks/nipype1/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pydra/tasks/nipype1/tests/test_nipype1task.py b/pydra/tasks/nipype1/tests/test_nipype1task.py
new file mode 100644
index 0000000..1f5c7c2
--- /dev/null
+++ b/pydra/tasks/nipype1/tests/test_nipype1task.py
@@ -0,0 +1,23 @@
+import pytest
+import shutil
+from pkg_resources import resource_filename
+
+from nipype.interfaces import fsl
+from pydra.tasks.nipype1.utils import Nipype1Task
+
+
+@pytest.mark.skipif(fsl.Info.version() is None, reason="Test requires FSL")
+def test_isolation(tmp_path):
+    in_file = tmp_path / "orig/tpms_msk.nii.gz"
+    in_file.parent.mkdir()
+    shutil.copyfile(resource_filename("nipype", "testing/data/tpms_msk.nii.gz"), in_file)
+
+    out_dir = tmp_path / "output"
+    out_dir.mkdir()
+
+    slicer = Nipype1Task(fsl.Slice(), cache_dir=str(out_dir))
+    slicer.inputs.in_file = in_file
+
+    res = slicer()
+    assert res.output.out_files
+    assert all(fname.startswith(str(out_dir)) for fname in res.output.out_files)