Skip to content
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

Fix worflows creation tutorial error #1645

Merged
merged 1 commit into from Oct 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 12 additions & 13 deletions doc/examples/workflow_creation.py
Expand Up @@ -10,9 +10,7 @@
line::

dipy_nlmeans t1.nii.gz t1_denoised.nii.gz
"""

"""
First create your workflow (let's name this workflow file as my_workflow.py). Usually this is a python file in
the ``<../dipy/workflows>`` directory.
"""
Expand All @@ -29,7 +27,6 @@
``Workflow`` is the base class that will be extended to create our workflow.
"""


class AppendTextFlow(Workflow):

def run(self, input_files, text_to_append='dipy', out_dir='',
Expand Down Expand Up @@ -57,8 +54,8 @@ def run(self, input_files, text_to_append='dipy', out_dir='',
text to a file.

It is mandatory to have out_dir as a parameter. It is also mandatory
to put 'out_' in front of every parameter that is going to be an
output. Lastly, all out_ params needs to be at the end of the params
to put `out_` in front of every parameter that is going to be an
output. Lastly, all `out_` params needs to be at the end of the params
list.

The ``run`` docstring is very important, you need to document every
Expand Down Expand Up @@ -87,30 +84,32 @@ def run(self, input_files, text_to_append='dipy', out_dir='',

The code in the loop is the actual workflow processing code. It can be anything.
For the example, it just appends text to an input file.
"""

"""

This is it for the workflow! Now to be able to call it easily via command
line, you need to add this bit of code. Usually this is in a separate
executable file located in ``bin``.
"""

The first line imports the run_flow method from the flow_runner class.
"""

The first line imports the run_flow method from the flow_runner class and the second
line imports the AppendTextFlow class from the newly created my_workflow.py file.
from dipy.workflows.flow_runner import run_flow

"""
The second line imports the ``AppendTextFlow`` class from the newly created
``my_workflow.py`` file. In this specific case, we comment this import
since ``AppendTextFlow`` class is not on an external file but in the current file.
"""

from dipy.workflows.flow_runner import run_flow
from dipy.workflows.my_workflow import AppendTextFlow
# from dipy.workflows.my_workflow import AppendTextFlow

"""
This is the method that will wrap everything that is needed to make a flow
command line ready then run it.
"""

if __name__ == "__main__":
run_flow(AppendTextFlow())

"""
This is the only thing needed to make your workflow available through command
line.
Expand Down