Skip to content

Commit 5b2c1fe

Browse files
author
Anton Khodak
committed
Merge branch 'master' into deprecate_drafts
2 parents 3b37cf3 + c48d882 commit 5b2c1fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1253
-380
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
In order to contribute to the development of ``cwltool``, you need to install cwltool from source (preferably in a virtual environment):
2+
Here's a rough
3+
- Install virtualenv via pip: ``pip install virtualenv``
4+
- Clone the cwltool: ``git clone https://github.com/common-workflow-language/cwltool.git``
5+
- Switch to cwltool directory: ``cd cwltool``
6+
- Create a virtual environment: ``virtualenv cwltool``
7+
- To begin using the virtual environment, it needs to be activated: ``source bin/activate``
8+
- To check if you have the virtual environment set up: ``which python`` and it should point to python executable in your virtual env
9+
- Install cwltool in the virtual environment: ``pip install .``
10+
- Check the version which might be different from the version installed in general on any system: ``cwltool --version``
11+
- After you've made the changes, you can the complete test suite via tox: ``tox``
12+
- If you want to run specific tests, say ``unit tests`` in Python 3.5, then: ``tox -e py35-unit``.
13+
- Look at ``tox.ini`` for all available tests and runtimes
14+
- If tests are passing, you can simply commit and create a PR on ``cwltool`` repo:
15+
- After you're done working on the ``cwltool``, you can deactivate the virtual environment: ``deactivate``

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include gittaggers.py Makefile cwltool.py
22
include tests/*
33
include tests/tmp1/tmp2/tmp3/.gitkeep
44
include tests/wf/*
5+
include tests/override/*
56
include cwltool/schemas/v1.0/*.yml
67
include cwltool/schemas/draft-2/*.yml
78
include cwltool/schemas/draft-3/*.yml
@@ -17,6 +18,7 @@ include cwltool/schemas/v1.1.0-dev1/*.md
1718
include cwltool/schemas/v1.1.0-dev1/salad/schema_salad/metaschema/*.yml
1819
include cwltool/schemas/v1.1.0-dev1/salad/schema_salad/metaschema/*.md
1920
include cwltool/cwlNodeEngine.js
21+
include cwltool/cwlNodeEngineJSConsole.js
2022
include cwltool/extensions.yml
2123
global-exclude *~
2224
global-exclude *.pyc

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pydocstyle_report.txt: $(PYSOURCES)
8989
pydocstyle setup.py $^ > pydocstyle_report.txt 2>&1 || true
9090

9191
diff_pydocstyle_report: pydocstyle_report.txt
92-
diff-quality --violations=pep8 $^
92+
diff-quality --violations=pycodestyle $^
9393

9494
## autopep8 : fix most Python code indentation and formatting
9595
autopep8: $(PYSOURCES)
@@ -160,7 +160,7 @@ mypy2: ${PYSOURCES}
160160
rm -Rf typeshed/2and3/schema_salad
161161
ln -s $(shell python -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
162162
typeshed/2and3/schema_salad
163-
MYPYPATH=$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
163+
MYPYPATH=$$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
164164
--warn-redundant-casts \
165165
cwltool
166166

@@ -171,7 +171,7 @@ mypy3: ${PYSOURCES}
171171
rm -Rf typeshed/2and3/schema_salad
172172
ln -s $(shell python3 -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
173173
typeshed/2and3/schema_salad
174-
MYPYPATH=$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
174+
MYPYPATH=$$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
175175
--warn-redundant-casts \
176176
cwltool
177177

README.rst

Lines changed: 123 additions & 37 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
@@ -33,7 +31,7 @@ It is highly recommended to setup virtual environment before installing `cwltool
3331
virtualenv -p python2 venv # Create a virtual environment, can use `python3` as well
3432
source venv/bin/activate # Activate environment before installing `cwltool`
3533
36-
1. Installing the official package from PyPi (will install "cwltool" package as
34+
Installing the official package from PyPi (will install "cwltool" package as
3735
well)
3836

3937
.. code:: bash
@@ -46,7 +44,7 @@ If installing alongside another CWL implementation then
4644
4745
pip install cwltool
4846
49-
2. To install from source
47+
Or you can install from source:
5048

5149
.. code:: bash
5250
@@ -64,9 +62,22 @@ Running tests locally
6462

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

65+
To run the basis tests after installing `cwltool` execute the following:
66+
6767
.. code:: bash
6868
69-
python setup.py test
69+
pip install pytest mock
70+
py.test --ignore cwltool/schemas/ --pyarg cwltool
71+
72+
To run various tests in all supported Python environments we use `tox <https://github.com/common-workflow-language/cwltool/tree/master/tox.ini>`_. To run the test suite in all supported Python environments
73+
first downloading the complete code repository (see the ``git clone`` instructions above) and then run
74+
the following in the terminal:
75+
``pip install tox; tox``
76+
77+
List of all environment can be seen using:
78+
``tox --listenvs``
79+
and running a specfic test env using:
80+
``tox -e <env name>``
7081

7182
- Running the entire suite of CWL conformance tests:
7283

@@ -102,6 +113,32 @@ and ``--tmp-outdir-prefix`` to somewhere under ``/Users``::
102113
.. |Build Status| image:: https://ci.commonwl.org/buildStatus/icon?job=cwltool-conformance
103114
:target: https://ci.commonwl.org/job/cwltool-conformance/
104115

116+
Using user-space replacements for Docker
117+
----------------------------------------
118+
119+
Some shared computing environments don't support Docker software containers for technical or policy reasons.
120+
As a work around, the CWL reference runner supports using a alternative ``docker`` implementations on Linux
121+
with the ``--user-space-docker-cmd`` option.
122+
123+
One such "user space" friendly docker replacement is ``udocker`` https://github.com/indigo-dc/udocker and another
124+
is ``dx-docker`` https://wiki.dnanexus.com/Developer-Tutorials/Using-Docker-Images
125+
126+
udocker installation: https://github.com/indigo-dc/udocker/blob/master/doc/installation_manual.md#22-install-from-indigo-datacloud-repositories
127+
128+
dx-docker installation: start with the DNAnexus toolkit (see https://wiki.dnanexus.com/Downloads for instructions).
129+
130+
Run `cwltool` just as you normally would, but with the new option, e.g. from the conformance tests:
131+
132+
.. code:: bash
133+
134+
cwltool --user-space-docker-cmd=udocker https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/v1.0/v1.0/test-cwl-out2.cwl https://github.com/common-workflow-language/common-workflow-language/blob/master/v1.0/v1.0/empty.json
135+
136+
or
137+
138+
.. code:: bash
139+
140+
cwltool --user-space-docker-cmd=dx-docker https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/v1.0/v1.0/test-cwl-out2.cwl https://github.com/common-workflow-language/common-workflow-language/blob/master/v1.0/v1.0/empty.json
141+
105142
Tool or workflow loading from remote or local locations
106143
-------------------------------------------------------
107144

@@ -137,13 +174,17 @@ For this example, grab the test.json (and input file) from https://github.com/Ca
137174
Import as a module
138175
------------------
139176

140-
Add::
177+
Add
178+
179+
.. code:: python
141180
142181
import cwltool
143182
144183
to your script.
145184

146-
The easiest way to use cwltool to run a tool or workflow from Python is to use a Factory::
185+
The easiest way to use cwltool to run a tool or workflow from Python is to use a Factory
186+
187+
.. code:: python
147188
148189
import cwltool.factory
149190
fac = cwltool.factory.Factory()
@@ -156,7 +197,7 @@ The easiest way to use cwltool to run a tool or workflow from Python is to use a
156197
Leveraging SoftwareRequirements (Beta)
157198
--------------------------------------
158199

159-
CWL tools may be decoarated with ``SoftwareRequirement`` hints that cwltool
200+
CWL tools may be decorated with ``SoftwareRequirement`` hints that cwltool
160201
may in turn use to resolve to packages in various package managers or
161202
dependency management systems such as `Environment Modules
162203
<http://modules.sourceforge.net/>`__.
@@ -185,24 +226,25 @@ following ``hint`` definition for an example CWL tool.
185226
- r93
186227
187228
Now imagine deploying cwltool on a cluster with Software Modules installed
188-
and that a ``seqtk`` module is avaialble at version ``r93``. This means cluster
189-
users likely won't have the ``seqtk`` the binary on their ``PATH`` by default but after
229+
and that a ``seqtk`` module is available at version ``r93``. This means cluster
230+
users likely won't have the binary ``seqtk`` on their ``PATH`` by default, but after
190231
sourcing this module with the command ``modulecmd sh load seqtk/r93`` ``seqtk`` is
191232
available on the ``PATH``. A simple dependency resolvers configuration file, called
192233
``dependency-resolvers-conf.yml`` for instance, that would enable cwltool to source
193234
the correct module environment before executing the above tool would simply be:
194235

195236
.. code:: yaml
196237
197-
- type: module
238+
- type: modules
198239
199240
The outer list indicates that one plugin is being enabled, the plugin parameters are
200241
defined as a dictionary for this one list item. There is only one required parameter
201242
for the plugin above, this is ``type`` and defines the plugin type. This parameter
202243
is required for all plugins. The available plugins and the parameters
203244
available for each are documented (incompletely) `here
204245
<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.
246+
Unfortunately, this documentation is in the context of Galaxy tool
247+
``requirement`` s instead of CWL ``SoftwareRequirement`` s, but the concepts map fairly directly.
206248

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

363-
Cwltool control flow
364-
--------------------
405+
Overriding workflow requirements at load time
406+
---------------------------------------------
407+
408+
Sometimes a workflow needs additional requirements to run in a particular
409+
environment or with a particular dataset. To avoid the need to modify the
410+
underlying workflow, cwltool supports requirement "overrides".
411+
412+
The format of the "overrides" object is a mapping of item identifier (workflow,
413+
workflow step, or command line tool) to the process requirements that should be applied.
414+
415+
.. code:: yaml
416+
417+
cwltool:overrides:
418+
echo.cwl:
419+
requirements:
420+
EnvVarRequirement:
421+
envDef:
422+
MESSAGE: override_value
423+
424+
Overrides can be specified either on the command line, or as part of the job
425+
input document. Workflow steps are identified using the name of the workflow
426+
file followed by the step name as a document fragment identifier "#id".
427+
Override identifiers are relative to the toplevel workflow document.
428+
429+
.. code:: bash
430+
431+
cwltool --overrides overrides.yml my-tool.cwl my-job.yml
432+
433+
.. code:: yaml
434+
435+
input_parameter1: value1
436+
input_parameter2: value2
437+
cwltool:overrides:
438+
workflow.cwl#step1:
439+
requirements:
440+
EnvVarRequirement:
441+
envDef:
442+
MESSAGE: override_value
443+
444+
.. code:: bash
445+
446+
cwltool my-tool.cwl my-job-with-overrides.yml
447+
448+
449+
CWL Tool Control Flow
450+
---------------------
365451

366452
Technical outline of how cwltool works internally, for maintainers.
367453

368-
#. Use CWL `load_tool()` to load document.
454+
#. Use CWL ``load_tool()`` to load document.
369455

370456
#. Fetches the document from file or URL
371457
#. Applies preprocessing (syntax/identifier expansion and normalization)
372458
#. Validates the document based on cwlVersion
373459
#. If necessary, updates the document to latest spec
374-
#. Constructs a Process object using `make_tool()` callback. This yields a
460+
#. Constructs a Process object using ``make_tool()``` callback. This yields a
375461
CommandLineTool, Workflow, or ExpressionTool. For workflows, this
376462
recursively constructs each workflow step.
377463
#. To construct custom types for CommandLineTool, Workflow, or
378-
ExpressionTool, provide a custom `make_tool()`
464+
ExpressionTool, provide a custom ``make_tool()``
379465

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

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
468+
#. ``job()`` is a generator method (uses the Python iterator protocol)
469+
#. Each time the ``job()`` method is invoked in an iteration, it returns one
470+
of: a runnable item (an object with a ``run()`` method), ``None`` (indicating
385471
there is currently no work ready to run) or end of iteration (indicating
386472
the process is complete.)
387-
#. Invoke the runnable item by calling `run()`. This runs the tool and gets output.
473+
#. Invoke the runnable item by calling ``run()``. This runs the tool and gets output.
388474
#. Output of a process is reported by an output callback.
389-
#. `job()` may be iterated over multiple times. It will yield all the work
475+
#. ``job()`` may be iterated over multiple times. It will yield all the work
390476
that is currently ready to run and then yield None.
391477

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

394480
#. The WorkflowJob iterates over each WorkflowJobStep and determines if the
395481
inputs the step are ready.
396482
#. 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.
483+
iterates on the ``job()`` method of the workflow job step.
398484
#. Each runnable item is yielded back up to top level run loop
399485
#. When a step job completes and receives an output callback, the
400486
job outputs are assigned to the output of the workflow step.
401487
#. When all steps are complete, the intermediate files are moved to a final
402488
workflow output, intermediate directories are deleted, and the output
403489
callback for the workflow is called.
404490

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

407-
#. The CommandLineTool `job()` method calls `makeJobRunner()` to create a
408-
`CommandLineJob` object
493+
#. The CommandLineTool ``job()`` method calls ``makeJobRunner()`` to create a
494+
``CommandLineJob`` object
409495
#. The job method configures the CommandLineJob object by setting public
410496
attributes
411497
#. The job method iterates over file and directories inputs to the
@@ -416,7 +502,7 @@ Technical outline of how cwltool works internally, for maintainers.
416502
#. Files are staged to targets paths using either Docker volume binds (when
417503
using containers) or symlinks (if not). This staging step enables files
418504
to be logically rearranged or renamed independent of their source layout.
419-
#. The run() method of CommandLineJob executes the command line tool or
505+
#. The ``run()`` method of CommandLineJob executes the command line tool or
420506
Docker container, waits for it to complete, collects output, and makes
421507
the output callback.
422508

cwltool/builder.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self): # type: () -> None
5151
self.stagedir = None # type: Text
5252
self.make_fs_access = None # type: Type[StdFsAccess]
5353
self.debug = False # type: bool
54+
self.js_console = False # type: bool
5455
self.mutation_manager = None # type: MutationManager
5556
self.force_docker_pull = False # type: bool
5657

@@ -206,7 +207,7 @@ def tostr(self, value): # type: (Any) -> Text
206207
def generate_arg(self, binding): # type: (Dict[Text,Any]) -> List[Text]
207208
value = binding.get("datum")
208209
if "valueFrom" in binding:
209-
with SourceLine(binding, "valueFrom", WorkflowException):
210+
with SourceLine(binding, "valueFrom", WorkflowException, _logger.isEnabledFor(logging.DEBUG)):
210211
value = self.do_eval(binding["valueFrom"], context=value)
211212

212213
prefix = binding.get("prefix")
@@ -256,5 +257,6 @@ def do_eval(self, ex, context=None, pull_image=True, recursive=False):
256257
self.resources,
257258
context=context, pull_image=pull_image,
258259
timeout=self.timeout,
259-
force_docker_pull=self.force_docker_pull,
260-
debug=self.debug)
260+
debug=self.debug,
261+
js_console=self.js_console,
262+
force_docker_pull=self.force_docker_pull)

0 commit comments

Comments
 (0)