Skip to content

Commit

Permalink
fixed duplicate output issue caused by replacement mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed May 14, 2024
1 parent 2f63f18 commit 28a2828
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nipype2pydra/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ def write(self, package_root: Path, to_include: ty.List[str] = None):

nipype_ports = []

for workflow in tqdm(workflows_to_include, "preparing workflows for writing"):
for workflow in tqdm(workflows_to_include, "parsing workflow statements"):
workflow.prepare()

for workflow in tqdm(workflows_to_include, "preparing workflow connections"):
for workflow in tqdm(workflows_to_include, "processing workflow connections"):
workflow.prepare_connections()

def collect_intra_pkg_objects(used: UsedSymbols, port_nipype: bool = True):
Expand Down
11 changes: 10 additions & 1 deletion nipype2pydra/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ def _parse_statements(self, func_body: str) -> ty.Tuple[
statements = split_source_into_statements(func_body)

parsed = []
outputs = []
workflow_init = None
workflow_init_index = None
assignments = defaultdict(list)
Expand Down Expand Up @@ -1104,7 +1105,15 @@ def _parse_statements(self, func_body: str) -> ty.Tuple[
conn_stmts = ConnectionStatement.parse(statement, self, assignments)
for conn_stmt in conn_stmts:
self._unprocessed_connections.append(conn_stmt)
if conn_stmt.wf_out or not conn_stmt.lzouttable:
if conn_stmt.wf_out:
if conn_stmt.conditional:
parsed.append(conn_stmt)
else:
outpt = self.get_output_from_conn(conn_stmt)
if outpt not in outputs:
parsed.append(conn_stmt)
outputs.append(outpt)
elif not conn_stmt.lzouttable:
parsed.append(conn_stmt)
parsed_stmt = conn_stmts[-1]
elif ReturnStatement.matches(statement):
Expand Down

0 comments on commit 28a2828

Please sign in to comment.