Skip to content

Commit 28a2828

Browse files
committed
fixed duplicate output issue caused by replacement mapping
1 parent 2f63f18 commit 28a2828

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

nipype2pydra/package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@ def write(self, package_root: Path, to_include: ty.List[str] = None):
365365

366366
nipype_ports = []
367367

368-
for workflow in tqdm(workflows_to_include, "preparing workflows for writing"):
368+
for workflow in tqdm(workflows_to_include, "parsing workflow statements"):
369369
workflow.prepare()
370370

371-
for workflow in tqdm(workflows_to_include, "preparing workflow connections"):
371+
for workflow in tqdm(workflows_to_include, "processing workflow connections"):
372372
workflow.prepare_connections()
373373

374374
def collect_intra_pkg_objects(used: UsedSymbols, port_nipype: bool = True):

nipype2pydra/workflow.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ def _parse_statements(self, func_body: str) -> ty.Tuple[
10561056
statements = split_source_into_statements(func_body)
10571057

10581058
parsed = []
1059+
outputs = []
10591060
workflow_init = None
10601061
workflow_init_index = None
10611062
assignments = defaultdict(list)
@@ -1104,7 +1105,15 @@ def _parse_statements(self, func_body: str) -> ty.Tuple[
11041105
conn_stmts = ConnectionStatement.parse(statement, self, assignments)
11051106
for conn_stmt in conn_stmts:
11061107
self._unprocessed_connections.append(conn_stmt)
1107-
if conn_stmt.wf_out or not conn_stmt.lzouttable:
1108+
if conn_stmt.wf_out:
1109+
if conn_stmt.conditional:
1110+
parsed.append(conn_stmt)
1111+
else:
1112+
outpt = self.get_output_from_conn(conn_stmt)
1113+
if outpt not in outputs:
1114+
parsed.append(conn_stmt)
1115+
outputs.append(outpt)
1116+
elif not conn_stmt.lzouttable:
11081117
parsed.append(conn_stmt)
11091118
parsed_stmt = conn_stmts[-1]
11101119
elif ReturnStatement.matches(statement):

0 commit comments

Comments
 (0)