Skip to content

Commit a896e2a

Browse files
authored
Merge branch 'master' into generation_warn
2 parents d4b76c5 + 2f5ddf4 commit a896e2a

File tree

4 files changed

+62
-55
lines changed

4 files changed

+62
-55
lines changed

README.rst

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
==================================================================
2-
Common workflow language tool description reference implementation
2+
Common Workflow Language tool description reference implementation
33
==================================================================
44

5-
CWL Conformance test: |Build Status|
6-
7-
Travis: |Unix Build Status|
5+
CWL conformance tests: |Build Status| Travis CI: |Unix Build Status|
86

97
.. |Unix Build Status| image:: https://img.shields.io/travis/common-workflow-language/cwltool/master.svg?label=unix%20build
108
:target: https://travis-ci.org/common-workflow-language/cwltool
119

1210
This is the reference implementation of the Common Workflow Language. It is
13-
intended to be feature complete and provide comprehensive validation of CWL
11+
intended to feature complete and provide comprehensive validation of CWL
1412
files as well as provide other tools related to working with CWL.
1513

16-
This is written and tested for Python 2.7.
14+
This is written and tested for Python ``2.7 and 3.x {x = 3, 4, 5, 6}``
1715

18-
The reference implementation consists of two packages. The "cwltool" package
16+
The reference implementation consists of two packages. The ``cwltool`` package
1917
is the primary Python module containing the reference implementation in the
20-
"cwltool" module and console executable by the same name.
18+
``cwltool`` module and console executable by the same name.
2119

22-
The "cwlref-runner" package is optional and provides an additional entry point
23-
under the alias "cwl-runner", which is the implementation-agnostic name for the
20+
The ``cwlref-runner`` package is optional and provides an additional entry point
21+
under the alias ``cwl-runner``, which is the implementation-agnostic name for the
2422
default CWL interpreter installed on a host.
2523

2624
Install
@@ -64,9 +62,15 @@ Running tests locally
6462

6563
- Running basic tests ``(/tests)``:
6664

67-
.. code:: bash
65+
We use `tox <https://github.com/common-workflow-language/cwltool/tree/master/tox.ini>`_
66+
to run various tests in all supported Python environments.
67+
You can run the test suite by simply running the following in the terminal:
68+
``pip install tox; tox``
6869

69-
python setup.py test
70+
List of all environment can be seen using:
71+
``tox --listenvs``
72+
and running a specfic test env using:
73+
``tox -e <env name>``
7074

7175
- Running the entire suite of CWL conformance tests:
7276

@@ -137,13 +141,17 @@ For this example, grab the test.json (and input file) from https://github.com/Ca
137141
Import as a module
138142
------------------
139143

140-
Add::
144+
Add
145+
146+
.. code:: python
141147
142148
import cwltool
143149
144150
to your script.
145151

146-
The easiest way to use cwltool to run a tool or workflow from Python is to use a Factory::
152+
The easiest way to use cwltool to run a tool or workflow from Python is to use a Factory
153+
154+
.. code:: python
147155
148156
import cwltool.factory
149157
fac = cwltool.factory.Factory()
@@ -202,7 +210,8 @@ for the plugin above, this is ``type`` and defines the plugin type. This paramet
202210
is required for all plugins. The available plugins and the parameters
203211
available for each are documented (incompletely) `here
204212
<https://docs.galaxyproject.org/en/latest/admin/dependency_resolvers.html>`__.
205-
Unfortunately, this documentation is in the context of Galaxy tool ``requirement`` s instead of CWL ``SoftwareRequirement`` s, but the concepts map fairly directly.
213+
Unfortunately, this documentation is in the context of Galaxy tool
214+
``requirement`` s instead of CWL ``SoftwareRequirement`` s, but the concepts map fairly directly.
206215

207216
cwltool is distributed with an example of such seqtk tool and sample corresponding
208217
job. It could executed from the cwltool root using a dependency resolvers
@@ -360,52 +369,52 @@ at the following links:
360369
- `Specifications - Implementation <https://github.com/galaxyproject/galaxy/commit/81d71d2e740ee07754785306e4448f8425f890bc>`__
361370
- `Initial cwltool Integration Pull Request <https://github.com/common-workflow-language/cwltool/pull/214>`__
362371

363-
Cwltool control flow
364-
--------------------
372+
CWL Tool Control Flow
373+
---------------------
365374

366375
Technical outline of how cwltool works internally, for maintainers.
367376

368-
#. Use CWL `load_tool()` to load document.
377+
#. Use CWL ``load_tool()`` to load document.
369378

370379
#. Fetches the document from file or URL
371380
#. Applies preprocessing (syntax/identifier expansion and normalization)
372381
#. Validates the document based on cwlVersion
373382
#. If necessary, updates the document to latest spec
374-
#. Constructs a Process object using `make_tool()` callback. This yields a
383+
#. Constructs a Process object using ``make_tool()``` callback. This yields a
375384
CommandLineTool, Workflow, or ExpressionTool. For workflows, this
376385
recursively constructs each workflow step.
377386
#. To construct custom types for CommandLineTool, Workflow, or
378-
ExpressionTool, provide a custom `make_tool()`
387+
ExpressionTool, provide a custom ``make_tool()``
379388

380-
#. Iterate on the `job()` method of the Process object to get back runnable jobs.
389+
#. Iterate on the ``job()`` method of the Process object to get back runnable jobs.
381390

382-
#. `job()` is a generator method (uses the Python iterator protocol)
383-
#. Each time the `job()` method is invoked in an iteration, it returns one
384-
of: a runnable item (an object with a `run()` method), `None` (indicating
391+
#. ``job()`` is a generator method (uses the Python iterator protocol)
392+
#. Each time the ``job()`` method is invoked in an iteration, it returns one
393+
of: a runnable item (an object with a ``run()`` method), ``None`` (indicating
385394
there is currently no work ready to run) or end of iteration (indicating
386395
the process is complete.)
387-
#. Invoke the runnable item by calling `run()`. This runs the tool and gets output.
396+
#. Invoke the runnable item by calling ``run()``. This runs the tool and gets output.
388397
#. Output of a process is reported by an output callback.
389-
#. `job()` may be iterated over multiple times. It will yield all the work
398+
#. ``job()`` may be iterated over multiple times. It will yield all the work
390399
that is currently ready to run and then yield None.
391400

392-
#. "Workflow" objects create a corresponding "WorkflowJob" and "WorkflowJobStep" objects to hold the workflow state for the duration of the job invocation.
401+
#. ``Workflow`` objects create a corresponding ``WorkflowJob`` and ``WorkflowJobStep`` objects to hold the workflow state for the duration of the job invocation.
393402

394403
#. The WorkflowJob iterates over each WorkflowJobStep and determines if the
395404
inputs the step are ready.
396405
#. When a step is ready, it constructs an input object for that step and
397-
iterates on the `job()` method of the workflow job step.
406+
iterates on the ``job()`` method of the workflow job step.
398407
#. Each runnable item is yielded back up to top level run loop
399408
#. When a step job completes and receives an output callback, the
400409
job outputs are assigned to the output of the workflow step.
401410
#. When all steps are complete, the intermediate files are moved to a final
402411
workflow output, intermediate directories are deleted, and the output
403412
callback for the workflow is called.
404413

405-
#. "CommandLineTool" job() objects yield a single runnable object.
414+
#. ``CommandLineTool`` job() objects yield a single runnable object.
406415

407-
#. The CommandLineTool `job()` method calls `makeJobRunner()` to create a
408-
`CommandLineJob` object
416+
#. The CommandLineTool ``job()`` method calls ``makeJobRunner()`` to create a
417+
``CommandLineJob`` object
409418
#. The job method configures the CommandLineJob object by setting public
410419
attributes
411420
#. The job method iterates over file and directories inputs to the
@@ -416,7 +425,7 @@ Technical outline of how cwltool works internally, for maintainers.
416425
#. Files are staged to targets paths using either Docker volume binds (when
417426
using containers) or symlinks (if not). This staging step enables files
418427
to be logically rearranged or renamed independent of their source layout.
419-
#. The run() method of CommandLineJob executes the command line tool or
428+
#. The ``run()`` method of CommandLineJob executes the command line tool or
420429
Docker container, waits for it to complete, collects output, and makes
421430
the output callback.
422431

cwltool/draft2tool.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,35 @@ def revmap_file(builder, outdir, f):
119119
# builder.outdir is the inner (container/compute node) output directory
120120
# outdir is the outer (host/storage system) output directory
121121

122-
if "location" in f:
122+
if "location" in f and "path" not in f:
123123
if f["location"].startswith("file://"):
124-
path = convert_pathsep_to_unix(uri_file_path(f["location"]))
125-
revmap_f = builder.pathmapper.reversemap(path)
126-
127-
if revmap_f and not builder.pathmapper.mapper(revmap_f[0]).type.startswith("Writable"):
128-
f["basename"] = os.path.basename(path)
129-
f["location"] = revmap_f[1]
130-
elif path == builder.outdir:
131-
f["location"] = outdir
132-
elif path.startswith(builder.outdir):
133-
f["location"] = builder.fs_access.join(outdir, path[len(builder.outdir) + 1:])
134-
elif f["location"].startswith(outdir):
135-
revmap_f = builder.pathmapper.reversemap(builder.fs_access.join(builder.outdir, f["location"][len(outdir) + 1:]))
136-
if revmap_f and not builder.pathmapper.mapper(revmap_f[0]).type.startswith("Writable"):
137-
f["basename"] = os.path.basename(path)
138-
f["location"] = revmap_f[1]
139-
return f
124+
f["path"] = convert_pathsep_to_unix(uri_file_path(f["location"]))
125+
else:
126+
return f
140127

141128
if "path" in f:
142129
path = f["path"]
130+
uripath = file_uri(path)
143131
del f["path"]
132+
133+
if "basename" not in f:
134+
f["basename"] = os.path.basename(path)
135+
144136
revmap_f = builder.pathmapper.reversemap(path)
145-
if revmap_f:
137+
138+
if revmap_f and not builder.pathmapper.mapper(revmap_f[0]).type.startswith("Writable"):
146139
f["location"] = revmap_f[1]
147-
return f
148-
elif path.startswith(builder.outdir):
140+
elif uripath == outdir or uripath.startswith(outdir+os.sep):
141+
f["location"] = file_uri(path)
142+
elif path == builder.outdir or path.startswith(builder.outdir+os.sep):
149143
f["location"] = builder.fs_access.join(outdir, path[len(builder.outdir) + 1:])
150-
return f
144+
elif not os.path.isabs(path):
145+
f["location"] = builder.fs_access.join(outdir, path)
151146
else:
152147
raise WorkflowException(u"Output file path %s must be within designated output directory (%s) or an input "
153148
u"file pass through." % (path, builder.outdir))
149+
return f
150+
154151

155152
raise WorkflowException(u"Output File object is missing both `location` and `path` fields: %s" % f)
156153

cwltool/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ def add_volumes(self, pathmapper, runtime, stage_output):
342342
createtmp = os.path.join(host_outdir, os.path.basename(vol.target))
343343
with open(createtmp, "wb") as f:
344344
f.write(vol.resolved.encode("utf-8"))
345-
runtime.append(u"--volume=%s:%s:ro" % (docker_windows_path_adjust(createtmp), docker_windows_path_adjust(vol.target)))
345+
if not vol.target.startswith(container_outdir):
346+
runtime.append(u"--volume=%s:%s:ro" % (docker_windows_path_adjust(createtmp), docker_windows_path_adjust(vol.target)))
346347

347348

348349
def run(self, pull_image=True, rm_container=True,

windowsdoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pip install cwltool
3737
```
3838
git clone https://github.com/common-workflow-language/cwltool.git
3939
cd cwltool
40-
python setup.py develop
40+
pip install .
4141
```
4242

4343
***Note:*** In order to test if cwltool has been successfully installed on your

0 commit comments

Comments
 (0)