Generation of CWL programmatically. Available types: Workflow, CommandLineTool and Requirements
Project description
python-cwlgen (deprecated)
Deprecated
python-cwlgen
is now deprecated, please use cwl-utils >= 0.4
.
from cwl_utils import parser_v1_0
# You could alias this as cwlgen to simplify the migration
from cwl_utils import parser_v1_0 as cwlgen
Migration notes:
-
Method changes
get_dict() → save()
parse_cwl(cwlfile)
→load_document(cwlfile)
parse_dict
→ No super clear analogue, but loaded through_RecordLoader(CommandLineTool)
||_UnionLoader((CommandLineToolLoader, ...workflow + other loaders)
-
Field names:
- Uses
camelCase
instead ofsnake_case
- No more special field names, eg:
tool_id
|workflow_id
|input_id
| etc →id
StepInput
:inputs
→in_
- Uses
-
Other notes:
-
Classes aren't nested anymore, ie:
cwlgen.InitialWorkDirRequirement.Dirent
→cwl_utils.parser_v1_0.Dirent
. -
Take care if you're migrating to a newer spec, as some classes might have changed names (notably:
InputParameter
->WorkflowInputParameter
) -
Don't forget to catch all references of cwlgen, as missing one (or using mismatch versions of the parser) will cause:
raise RepresenterError('cannot represent an object: %s' % (data,)) ruamel.yaml.representer.RepresenterError: cannot represent an object: <cwlgen.common.CommandInputArraySchema object at 0x1100a5780>
-
If you have issues with the migration, please see this thread or raise an issue on CWLUtils.
Original README
Python-cwlgen is a python library for the generation of CWL programmatically. It supports the generation of CommandLineTool, Workflow and DockerRequirement. The library works for both Python 2.7.12+ and 3.6.0.
Common Workflow Language
Common Workflow Language (CWL) is a language to describe workflows. The user guide gives a gentle explanation of what its goals are, but broadly:
- Stop writing bash scripts for long complex jobs.
- Take pipelines anywhere (portability).
- Enforce reproducibility guidelines.
This python repository is a python wrapper for most of the classes (work in progress), allowing you to build the structure of the workflow in Python and have this module generate and export CWL for you.
Nb: This doesn't check the logic of Workflows or CommandLineTools for you.
CWLTool has a --validate
mode that you can use.
Quick-start guide
You can install python-cwlgen through pip with the following command:
pip install cwlgen
How it works?
This repository contains a number of python classes that mirror the CWL specifications (Workflow| CommandLineTool). In essence, each class's initializer has all of the properties it expects, which may be another object. The classes include the relevant docstrings to give you context of classes and their properties.
The examples/
folder contains some simple examples, however in essence you simply initialize the class you're
trying to build. An initializer for a class has all of the properties it expects which may be another object.
Creating a CommandLineTool
import cwlgen
tool_object = cwlgen.CommandLineTool(tool_id="echo-tool", base_command="echo", label=None, doc=None,
cwl_version="v1.0", stdin=None, stderr=None, stdout=None, path=None)
tool_object.inputs.append(
cwlgen.CommandInputParameter("myParamId", param_type="string", label=None, secondary_files=None, param_format=None,
streamable=None, doc=None, input_binding=None, default=None)
)
# to get the dictionary representation:
dict_to_export = tool_object.get_dict()
# to get the string representation (YAML)
yaml_export = tool_object.export_string()
# print to console
tool_object.export()
# print to file
tool_object.export("echotool.cwl")
References
CWL is developed by an informal, multi-vendor working group consisting of organizations and individuals aiming to enable scientists to share data analysis workflows. The CWL project is on Github.
Known issues
SchemaDefRequirement
doesn't parse thetypes
subfield into the specific types (InputRecordSchema | InputEnumSchema | InputArraySchema
), but leaves them as a simple dictionary.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cwlgen-0.4.2.tar.gz
.
File metadata
- Download URL: cwlgen-0.4.2.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ee26cddc0f352dd485fc11696711b810b7b8bf4f4a39b33f481294fc0b0c2a0 |
|
MD5 | 38d51386d206c8e65c67de0f79525c55 |
|
BLAKE2b-256 | 8a5461e02f54e450695e8ad4e560c86f6a046c85b180973ae7dda818375d4eb2 |