Package: cwlgen
python-cwlgen (deprecated)Deprecatedpython-cwlgenis now deprecated, please usecwl-utils >= 0.4.fromcwl_utilsimportparser_v1_0# You could alias this as cwlgen to simplify the migrationfromcwl_utilsimportparser_v1_0ascwlgenMigration notes:Method changesget_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:UsescamelCaseinstead ofsnake_caseNo more special field names, eg:tool_id|workflow_id|input_id| etc →idStepInput:inputs→in_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:raiseRepresenterError('cannot represent an object:%s'%(data,))ruamel.yaml.representer.RepresenterError:cannotrepresentanobject:<cwlgen.common.CommandInputArraySchemaobjectat0x1100a5780>If you have issues with the migration, please seethis threador raise an issue on CWLUtils.Original READMEPython-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 LanguageCommon Workflow Language (CWL)is a language to describe workflows.
Theuser guidegives 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 formostof 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.CWLToolhas a--validatemode that you can use.Quick-start guideYou can install python-cwlgen through pip with the following command:pipinstallcwlgenHow 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.Theexamples/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 CommandLineToolimportcwlgentool_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 consoletool_object.export()# print to filetool_object.export("echotool.cwl")ReferencesCWL is developed by an informal, multi-vendor working group consisting of organizations and individuals
aiming to enable scientists to share data analysis workflows.
TheCWL project is on Github.Known issuesSchemaDefRequirementdoesn't parse thetypessubfield into the specific types
(InputRecordSchema | InputEnumSchema |  InputArraySchema), but leaves them as a simple dictionary.