Skip to content

[WIP] Add state/mappers to new workflow syntax #2648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

djarecka
Copy link
Collaborator

adding my mapping and submitter to #2629. Had problem with merging NewNode with my submitter without creating an extra class NewNodeBase and treating NewNode as a wrapper that runs nodes's interface.

NeeWorkflows inherits from NewNode.

For now, I only added things related mapper, ignored join and joindByKey.

djarecka added 21 commits July 10, 2018 11:41
…anging State.state_value so it returns values (and not arrays)
… SubmitterWorkflow class; simple test for NewNode.run using SubmitterNode
… had to create a new class and have now NewNodeBase and NewNode that is a wrapper with the run method
…can use it for NewWorkflow; creating prepare_state_input in State from the __init__, so I can initialize State before having input
…dd_nodes, that takes nodes with mapper, tested; didnt work on map method; resume using state_inputs (since this is the inputs that I have before a workflow run and I can specify state_values based on it, etc.)
@djarecka djarecka changed the title Effigies enh/workflow syntax + state/mappers [WIP] Effigies enh/workflow syntax + state/mappers Jul 25, 2018
@effigies
Copy link
Member

effigies commented Jul 25, 2018

This is no longer compatible with mine and it's hard to see the changes. I'm going to push to upstream so that you can do a PR against mine.

@effigies effigies changed the base branch from master to enh/workflow_syntax July 25, 2018 13:58
@codecov-io
Copy link

codecov-io commented Jul 25, 2018

Codecov Report

❗ No coverage uploaded for pull request base (enh/workflow_syntax@ffed595). Click here to learn what that means.
The diff coverage is 85.93%.

Impacted file tree graph

@@                  Coverage Diff                   @@
##             enh/workflow_syntax    #2648   +/-   ##
======================================================
  Coverage                       ?   64.48%           
======================================================
  Files                          ?      343           
  Lines                          ?    43720           
  Branches                       ?     5513           
======================================================
  Hits                           ?    28192           
  Misses                         ?    14430           
  Partials                       ?     1098
Flag Coverage Δ
#unittests 64.48% <85.93%> (?)
Impacted Files Coverage Δ
nipype/info.py 88.05% <ø> (ø)
nipype/pipeline/engine/__init__.py 100% <100%> (ø)
nipype/exceptions.py 100% <100%> (ø)
nipype/pipeline/engine/auxiliary.py 78.03% <78.03%> (ø)
nipype/pipeline/engine/state.py 78.57% <78.57%> (ø)
nipype/pipeline/engine/workflows.py 77.02% <86.75%> (ø)
nipype/pipeline/engine/workers.py 93.44% <93.44%> (ø)
nipype/pipeline/engine/submitter.py 93.49% <93.49%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ffed595...2e3ea2a. Read the comment docs.

@effigies effigies changed the title [WIP] Effigies enh/workflow syntax + state/mappers [WIP] Add state/mappers to new workflow syntax Jul 25, 2018
@djarecka
Copy link
Collaborator Author

@effigies - not completely sure what do you want me to do. I can see that you actually committed to this PR, so do you still want me to create PR to your fork?

@effigies
Copy link
Member

No, I updated this. You should be able to git pull and be on the same page.

@djarecka
Copy link
Collaborator Author

@effigies - got it, pulled all changes

@djarecka
Copy link
Collaborator Author

@mgxd - do you know where I can find an example that used FreeSurfer? I already have access to my account on openmind, so you can just provide the path.

@effigies
Copy link
Member

I'm finally getting back to this. I'm sorry to keep being confused by simple things, but I can't really tell what the open problems are at this point. What kind of input are you hoping for?

@djarecka
Copy link
Collaborator Author

@effigies - right now I'm changing a few important things in Workflow, since I already started it might be better for now to wait till I finish and push changes.

I'm also trying to produce input for the Satra example.

@djarecka
Copy link
Collaborator Author

@effigies - I run fmriprep, but I have problem with finding 'func_preproc_task_rest_run_1_wf/bold_reg_wf/merge/.nii'.

workdir1/fmriprep_wf/single_subject_01_wf/func_preproc_ses_test_task_fingerfootlips_wf/bold_reg_wf/
├── bbreg_wf
│   ├── bbregister
│   │   ├── _0xf70f8caf16da2567ae41d2a23b54985f.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── command.txt
│   │   ├── report.svg
│   │   ├── result_bbregister.pklz
│   │   └── uni_xform_masked_bbreg_sub-01.lta
│   ├── compare_transforms
│   │   ├── _0x7d0ffcbb945b9b470b0ff8f3d0dc0227.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   └── result_compare_transforms.pklz
│   ├── fsl2itk_fwd
│   │   ├── _0xb7914a3f1e15b93248bf04e8e622fba3.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── affine.txt
│   │   ├── command.txt
│   │   └── result_fsl2itk_fwd.pklz
│   ├── fsl2itk_inv
│   │   ├── _0xa44c5cc463a48c24a800dc4330c8a8ae.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── affine.txt
│   │   ├── command.txt
│   │   └── result_fsl2itk_inv.pklz
│   ├── lta2fsl_fwd
│   │   ├── _0x3bf54e0d0abc56462dcfa66064d9e998.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── command.txt
│   │   ├── out.mat
│   │   └── result_lta2fsl_fwd.pklz
│   ├── lta2fsl_inv
│   │   ├── _0x55800097b9abae53f24d52e39943a3c3.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── command.txt
│   │   ├── out.mat
│   │   └── result_lta2fsl_inv.pklz
│   ├── lta_concat
│   │   ├── _0xd849f4a3e4ad946a8373b596fd77e897.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── command.txt
│   │   ├── out.lta
│   │   └── result_lta_concat.pklz
│   ├── lta_ras2ras
│   │   ├── _0xf8921b88a27e07aa44a4f4d1843963d7.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── mapflow
│   │   │   ├── _lta_ras2ras0
│   │   │   │   ├── _0xae9756590c1d6dda99b11915c2787266.json
│   │   │   │   ├── _inputs.pklz
│   │   │   │   ├── _node.pklz
│   │   │   │   ├── _report
│   │   │   │   │   └── report.rst
│   │   │   │   ├── command.txt
│   │   │   │   ├── out.lta
│   │   │   │   └── result__lta_ras2ras0.pklz
│   │   │   └── _lta_ras2ras1
│   │   │       ├── _0x5d988e699d4e3a57b27e085ba5ffec63.json
│   │   │       ├── _inputs.pklz
│   │   │       ├── _node.pklz
│   │   │       ├── _report
│   │   │       │   └── report.rst
│   │   │       ├── command.txt
│   │   │       ├── out.lta
│   │   │       └── result__lta_ras2ras1.pklz
│   │   └── result_lta_ras2ras.pklz
│   ├── mri_coreg
│   │   ├── _0x1b331d4c22263c780ed484555cf49a25.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   ├── command.txt
│   │   ├── registration.lta
│   │   ├── report.svg
│   │   └── result_mri_coreg.pklz
│   ├── reports
│   │   ├── _0xc4c5c4023fa71a99013862601ab1791a.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   └── result_reports.pklz
│   ├── select_report
│   │   ├── _0xb7109ac43e4683df17159827d88ec9ce.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   └── result_select_report.pklz
│   ├── select_transform
│   │   ├── _0x311f1aaed90e9ad11494a24d87d442f5.json
│   │   ├── _inputs.pklz
│   │   ├── _node.pklz
│   │   ├── _report
│   │   │   └── report.rst
│   │   └── result_select_transform.pklz
│   └── transforms
│       ├── _0x4ed9f598f64c971a186cafa1aabaaa9c.json
│       ├── _inputs.pklz
│       ├── _node.pklz
│       ├── _report
│       │   └── report.rst
│       └── result_transforms.pklz
└── ds_report_reg
    ├── _0xfd3e561f50d13155654d010e1a0382cb.json
    ├── _inputs.pklz
    ├── _node.pklz
    ├── _report
    │   └── report.rst
    └── result_ds_report_reg.pklz

@djarecka
Copy link
Collaborator Author

I've realized that I'm not sure if I chose the right --output-space, since I only used fsaverage5. Should I also use fsnative?

@effigies
Copy link
Member

Sorry, it should have been func_preproc_task_rest_run_1_wf/bold_t1_trans_wf/merge/*.nii*.

You can use whatever output spaces you want, as long as they exist in your FreeSurfer directory.

@effigies effigies added this to the Nipype 2.0 milestone Sep 28, 2018
… changing output/result in Node and Workflow
…checking inputs/outputs, changing submitter; finishing mapper for workflow: adding inner nodes, parent workflow is used to collect results, changing submitter; reorganization of SubmitterWorkflow (still have both: SubmitterNode and SubmitterWorkflow)
Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments on the neuro workflow. If this works (does it?), I think we're not too far away from a decent syntax.


wf.add(runnable=select_target, name="targets", subject_id="subject_id")\
.map(mapper="space", inputs={"space": [space for space in Inputs["output_spaces"]
if space.startswith("fs")]})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we switch to a generator, we could do:

      .map("space", space=(space for space in wf.inputs.output_spaces
                           if space.startswith('fs')))

That would allow us to lazily evaluate wf.inputs.output_spaces at expansion time.


#dj: don't have option in map to connect with wf input

wf.add(runnable=select_target, name="targets", subject_id="subject_id")\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to go back to @satra's syntax from #2539 (comment):

wf.add('targets', select_target, subject_id=wf.inputs.subject_id)\

I know the last will require that wf.inputs attributes be futures, so leaving that as a string for now is fine. But it would make the protocol:

class Workflow:
    ...
    def add(self, name, runnable, **input_map):
        ...

By the way, I think it might be more consistent to use 'inputs.subject_id', treating wf.inputs as a node. Since we're using wf.add, the method should know the namespace we're working in.

wf.add(name='rename_src',
runnable=Rename(format_string='%(subject)s', keep_ext=True),
in_file="source_file", subject="subject_id")\
.map('subject')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here what we actually want is:

wf.add('rename_src', Rename(format_string='%(subject)s', keep_ext=True),
       in_file="inputs.source_file", subject="select_target.out")

The mapping is already being done at select_target. Since these are no longer MapNodes, we don't need to re-map unless we join first.

@djarecka
Copy link
Collaborator Author

djarecka commented Oct 4, 2018

@effigies - recently I've mostly working on the engine itself, but today I'll also try to work on this example. Have to merge current interfaces/nodes with my new workflow.

@effigies
Copy link
Member

effigies commented Oct 4, 2018

Cool. If there are engine-related things you'd like input on, could you comment on the relevant tests?

… adding flag that says if values or indecies are used in directories names and output
…_ci_output that reads output path from results*.pklz; adding print_val flag to Node/Workflow that says if an input value (or index) should be used in directories name; adding out_read flag to FunctionInterface that says if the value from the file should be saved in the output (instead of path)
@effigies
Copy link
Member

This is all moved to pydra.

@effigies effigies closed this Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants