Skip to content

Commit

Permalink
write paremeters order in pipeline .py export
Browse files Browse the repository at this point in the history
because they are otherwise exported in an uncontrolled order depending
on the links iteration orders (populse/populse_mia#236)
  • Loading branch information
denisri committed Mar 18, 2022
1 parent 297fe1b commit 9799135
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions capsul/pipeline/python_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ def _write_links(pipeline, pyf):
print(' self.add_link("%s->%s"%s)'
% (src, dst, weak_link), file=pyf)

def _write_param_order(pipeline, pyf):
if len(pipeline.user_traits()) == 0:
return
print('\n # parameters order', file=pyf)
names = ['"%s"' % n for n in pipeline.user_traits().keys()
if n not in ('nodes_activation', 'pipeline_steps',
'visible_groups')]
print('\n self.reorder_traits((%s))'
% ', '.join(names), file=pyf)

def _write_steps(pipeline, pyf):
steps = pipeline.trait('pipeline_steps')
if steps and getattr(pipeline, 'pipeline_steps', None):
Expand Down Expand Up @@ -433,6 +443,7 @@ def _write_values(pipeline, pyf):

_write_processes(pipeline, pyf)
_write_links(pipeline, pyf)
_write_param_order(pipeline, pyf)
_write_processes_selections(pipeline, pyf)
_write_steps(pipeline, pyf)
_write_values(pipeline, pyf)
Expand Down

0 comments on commit 9799135

Please sign in to comment.