You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The easiest way to use cwltool to run a tool or workflow from Python is to use a Factory::
91
+
92
+
import cwltool.factory
93
+
fac = cwltool.factory.Factory()
94
+
95
+
echo = f.make("echo.cwl")
96
+
result = echo(inp="foo")
97
+
98
+
# result["out"] == "foo"
99
+
100
+
101
+
Cwltool control flow
102
+
--------------------
103
+
104
+
#. Use CWL `load_tool()` to load document.
105
+
106
+
#. Fetches the document from file or URL
107
+
#. Applies preprocessing (syntax/identifier expansion and normalization)
108
+
#. Validates the document based on cwlVersion
109
+
#. If necessary, updates the document to latest spec
110
+
#. Constructs a Process object using `make_tool()` callback. This yields a
111
+
CommandLineTool, Workflow, or ExpressionTool. For workflows, this
112
+
recursively constructs each workflow step.
113
+
#. To construct custom types for CommandLineTool, Workflow, or
114
+
ExpressionTool, provide a custom `make_tool()`
115
+
116
+
#. Iterate on the `job()` method of the Process object to get back runnable jobs.
117
+
118
+
#. `job()` is a generator method (uses the Python iterator protocol)
119
+
#. Each time the `job()` method is invoked in an iteration, it returns one
120
+
of: a runnable item (an object with a `run()` method), `None` (indicating
121
+
there is currently no work ready to run) or end of iteration (indicating
122
+
the process is complete.)
123
+
#. Invoke the runnable item by calling `run()`. This runs the tool and gets output.
124
+
#. Output of a process is reported by an output callback.
125
+
#. `job()` may be iterated over multiple times. It will yield all the work
126
+
that is currently ready to run and then yield None.
127
+
128
+
#. "Workflow" objects create a corresponding "WorkflowJob" and "WorkflowJobStep" objects to hold the workflow state for the duration of the job invocation.
129
+
130
+
#. The WorkflowJob iterates over each WorkflowJobStep and determines if the
131
+
inputs the step are ready.
132
+
#. When a step is ready, it constructs an input object for that step and
133
+
iterates on the `job()` method of the workflow job step.
134
+
#. Each runnable item is yielded back up to top level run loop
135
+
#. When a step job completes and receives an output callback, the
136
+
job outputs are assigned to the output of the workflow step.
137
+
#. When all steps are complete, the intermediate files are moved to a final
138
+
workflow output, intermediate directories are deleted, and the output
139
+
callback for the workflow is called.
140
+
141
+
#. "CommandLineTool" job() objects yield a single runnable object.
142
+
143
+
#. The CommandLineTool `job()` method calls `makeJobRunner()` to create a
144
+
`CommandLineJob` object
145
+
#. The job method configures the CommandLineJob object by setting public
146
+
attributes
147
+
#. The job method iterates over file and directories inputs to the
148
+
CommandLineTool and creates a "path map".
149
+
#. Files are mapped from their "resolved" location to a "target" path where
150
+
they will appear at tool invocation (for example, a location inside a
151
+
Docker container.) The target paths are used on the command line.
152
+
#. Files are staged to targets paths using either Docker volume binds (when
153
+
using containers) or symlinks (if not). This staging step enables files
154
+
to be logically rearranged or renamed independent of their source layout.
155
+
#. The run() method of CommandLineJob executes the command line tool or
156
+
Docker container, waits for it to complete, collects output, and makes
157
+
the output callback.
158
+
159
+
160
+
Extension points
161
+
----------------
162
+
163
+
The following functions can be provided to main(), to load_tool(), or to the
164
+
executor to override or augment the listed behaviors.
0 commit comments