diff --git a/cwlgen/commandlinetool.py b/cwlgen/commandlinetool.py index af5e5a3..337750a 100644 --- a/cwlgen/commandlinetool.py +++ b/cwlgen/commandlinetool.py @@ -17,12 +17,12 @@ class CommandOutputBinding(Serializable): - ''' + """ Describes how to generate an output parameter based on the files produced. - ''' + """ def __init__(self, glob=None, load_contents=None, output_eval=None): - ''' + """ :param glob: Find corresponding file(s) :type glob: STRING :param load_contents: For each file matched, read up to the 1st 64 KiB of text and @@ -30,7 +30,7 @@ def __init__(self, glob=None, load_contents=None, output_eval=None): :type load_contents: BOOLEAN :param output_eval: Evaluate an expression to generate the output value :type output_eval: STRING - ''' + """ self.glob = glob self.loadContents = load_contents self.outputEval = output_eval @@ -43,9 +43,19 @@ class CommandInputParameter(Parameter): parse_types = {"inputBinding": [CommandLineBinding]} - def __init__(self, param_id, label=None, secondary_files=None, param_format=None, - streamable=None, doc=None, input_binding=None, default=None, param_type=None): - ''' + def __init__( + self, + param_id, + label=None, + secondary_files=None, + param_format=None, + streamable=None, + doc=None, + input_binding=None, + default=None, + param_type=None, + ): + """ :param param_id: unique identifier for this parameter :type param_id: STRING :param label: short, human-readable label @@ -66,24 +76,40 @@ def __init__(self, param_id, label=None, secondary_files=None, param_format=None :type default: STRING :param param_type: type of data assigned to the parameter corresponding to CWLType :type param_type: STRING - ''' - Parameter.__init__(self, param_id=param_id, label=label, - secondary_files=secondary_files, param_format=param_format, - streamable=streamable, doc=doc, param_type=param_type) + """ + Parameter.__init__( + self, + param_id=param_id, + label=label, + secondary_files=secondary_files, + param_format=param_format, + streamable=streamable, + doc=doc, + param_type=param_type, + ) self.inputBinding = input_binding self.default = default class CommandOutputParameter(Parameter): - ''' + """ An output parameter for a :class:`cwlgen.CommandLineTool`. - ''' + """ parse_types = {"outputBinding": [CommandOutputBinding]} - def __init__(self, param_id, label=None, secondary_files=None, param_format=None, - streamable=None, doc=None, output_binding=None, param_type=None): - ''' + def __init__( + self, + param_id, + label=None, + secondary_files=None, + param_format=None, + streamable=None, + doc=None, + output_binding=None, + param_type=None, + ): + """ :param param_id: unique identifier for this parameter :type param_id: STRING :param label: short, human-readable label @@ -102,27 +128,45 @@ def __init__(self, param_id, label=None, secondary_files=None, param_format=None :type output_binding: :class:`cwlgen.CommandOutputBinding` object :param param_type: type of data assigned to the parameter corresponding to CWLType :type param_type: STRING - ''' - Parameter.__init__(self, param_id, label, secondary_files, param_format, streamable, - doc, param_type) + """ + Parameter.__init__( + self, + param_id, + label, + secondary_files, + param_format, + streamable, + doc, + param_type, + ) self.outputBinding = output_binding class CommandLineTool(Serializable): - ''' + """ Contain all informations to describe a CWL command line tool. - ''' + """ - __CLASS__ = 'CommandLineTool' + __CLASS__ = "CommandLineTool" parse_types = {'inputs': [[CommandInputParameter]], "outputs": [[CommandOutputParameter]]} ignore_fields_on_parse = ["namespaces", "class"] ignore_fields_on_convert = ["namespaces", "class", "metadata", "requirements"] - def __init__(self, tool_id=None, base_command=None, label=None, doc=None, - cwl_version=None, stdin=None, stderr=None, stdout=None, path=None): - ''' - :param tool_id: unique identifier for this tool + def __init__( + self, + tool_id=None, + base_command=None, + label=None, + doc=None, + cwl_version=None, + stdin=None, + stderr=None, + stdout=None, + path=None + ): + """ + :param tool_id: Unique identifier for this tool :type tool_id: str :param base_command: command line for the tool :type base_command: str | list[STRING] @@ -145,9 +189,13 @@ def __init__(self, tool_id=None, base_command=None, label=None, doc=None, hints (any | :class:`cwlgen.Requirement` objects) and requirements (:class:`cwlgen.Requirement` objects) are stored in lists which are initialized empty. - ''' + """ if cwl_version not in CWL_VERSIONS: - _LOGGER.warning("CWL version {} is not recognized as a valid version.".format(cwl_version)) + _LOGGER.warning( + "CWL version {} is not recognized as a valid version.".format( + cwl_version + ) + ) _LOGGER.warning("CWL version is set up to {}.".format(DEF_VERSION)) cwl_version = DEF_VERSION self.cwlVersion = cwl_version @@ -174,7 +222,7 @@ def get_dict(self): d = super(CommandLineTool, self).get_dict() - d['class'] = self.__CLASS__ + d["class"] = self.__CLASS__ if self.metadata: for key, value in self.metadata.__dict__.items(): @@ -182,11 +230,11 @@ def get_dict(self): # - Add Namespaces d[self.namespaces.name] = {} for k, v in self.namespaces.__dict__.items(): - if '$' not in v: + if "$" not in v: d[self.namespaces.name][k] = v if self.requirements: - d['requirements'] = {r.get_class(): r.get_dict() for r in self.requirements} + d["requirements"] = {r.get_class(): r.get_dict() for r in self.requirements} return d def export_string(self): @@ -202,10 +250,10 @@ def export(self, outfile=None): # Write CWL file in YAML if outfile is None: - six.print_(CWL_SHEBANG, "\n", sep='') + six.print_(CWL_SHEBANG, "\n", sep="") six.print_(rep) else: - out_write = open(outfile, 'w') - out_write.write(CWL_SHEBANG + '\n\n') + out_write = open(outfile, "w") + out_write.write(CWL_SHEBANG + "\n\n") out_write.write(rep) out_write.close() diff --git a/cwlgen/version.py b/cwlgen/version.py index a37c467..4aeae11 100644 --- a/cwlgen/version.py +++ b/cwlgen/version.py @@ -1,2 +1,2 @@ -version_info = (0, 2, 8) -__version__ = '.'.join(str(c) for c in version_info) +version_info = (0, 3, 0) +__version__ = ".".join(str(c) for c in version_info) diff --git a/doc/source/changelogs.rst b/doc/source/changelogs.rst index 17fb59f..951cb39 100644 --- a/doc/source/changelogs.rst +++ b/doc/source/changelogs.rst @@ -8,6 +8,18 @@ Changelogs Summary of developments of Python-cwlgen library. +v0.3 +==== + +v0.3.0 +------ + +This update brings more completeness to the v1.0 spec. + +* Large increase in the number of supported classes +* New translation mechanism +* More docstrings + v0.2 ==== diff --git a/doc/source/classes.rst b/doc/source/classes.rst index a1393a3..e852c6c 100644 --- a/doc/source/classes.rst +++ b/doc/source/classes.rst @@ -1,140 +1,197 @@ .. python-cwlgen - Python library for manipulation and generation of CWL tools. -.. _classes: - *********** API classes *********** -.. _cwl_tool: +Workflow and CommandLineTool +============================ + +See the links below to the `CommandLineTool` and `Workflow` classes: + +- :class:`cwlgen.CommandLineTool` +- :class:`cwlgen.Workflow` + +Requirements +============ -CWL Tool -======== +Requirement +""""""""""" -CommandLineTool -""""""""""""""" +This is the (abstract) base requirement class. -.. autoclass:: cwlgen.CommandLineTool +.. autoclass:: cwlgen.Requirement :members: :private-members: :special-members: :exclude-members: __weakref__ -.. _cwl_workflow: +InlineJavascriptReq +""""""""""""""""""" -CWL Workflow -============ +.. autoclass:: cwlgen.InlineJavascriptReq + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +SchemaDefRequirement +"""""""""""""""""""" -Workflow -"""""""" +See the Schema section Below: -.. autoclass:: cwlgen.workflow.Workflow +- :class:`cwlgen.SchemaDefRequirement` + + +SubworkflowFeatureRequirement +""""""""""""""""""""""""""""" + +.. autoclass:: cwlgen.SubworkflowFeatureRequirement :members: :private-members: :special-members: :exclude-members: __weakref__ -InputParameter -"""""""""""""" +ScatterFeatureRequirement +"""""""""""""""""""""""""" -.. autoclass:: cwlgen.workflow.InputParameter +.. autoclass:: cwlgen.ScatterFeatureRequirement :members: :private-members: :special-members: :exclude-members: __weakref__ -WorkflowStep -"""""""""""" +MultipleInputFeatureRequirement +""""""""""""""""""""""""""""""" -.. autoclass:: cwlgen.workflow.WorkflowStep +.. autoclass:: cwlgen.MultipleInputFeatureRequirement :members: :private-members: :special-members: :exclude-members: __weakref__ +StepInputExpressionRequirement +""""""""""""""""""""""""""""""" -.. _in_out: - -Input and outputs -================= +.. autoclass:: cwlgen.StepInputExpressionRequirement + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ -CommandInputParameter -""""""""""""""""""""" +DockerRequirement +""""""""""""""""" -.. autoclass:: cwlgen.CommandInputParameter +.. autoclass:: cwlgen.DockerRequirement :members: :private-members: :special-members: :exclude-members: __weakref__ -CommandOutputParameter -"""""""""""""""""""""" +SoftwareRequirement +""""""""""""""""""" -.. autoclass:: cwlgen.CommandOutputParameter +.. autoclass:: cwlgen.SoftwareRequirement + :members: + :private-members: + :special-members: + :exclude-members: SoftwarePackage,__weakref__ + +.. autoclass:: cwlgen.SoftwareRequirement.SoftwarePackage :members: :private-members: :special-members: :exclude-members: __weakref__ -CommandLineBinding -"""""""""""""""""" -.. autoclass:: cwlgen.CommandLineBinding +InitialWorkDirRequirement +"""""""""""""""""""""""""" + +.. autoclass:: cwlgen.InitialWorkDirRequirement + :members: + :private-members: + :special-members: + :exclude-members: Dirent,__weakref__ + +.. autoclass:: cwlgen.InitialWorkDirRequirement.Dirent :members: :private-members: :special-members: :exclude-members: __weakref__ -CommandOutputBinding -"""""""""""""""""""" -.. autoclass:: cwlgen.CommandOutputBinding +EnvVarRequirement +""""""""""""""""""" + +.. autoclass:: cwlgen.EnvVarRequirement + :members: + :private-members: + :special-members: + :exclude-members: EnvironmentDef,__weakref__ + +.. autoclass:: cwlgen.EnvVarRequirement.EnvironmentDef :members: :private-members: :special-members: :exclude-members: __weakref__ -CommandInputArraySchema +ShellCommandRequirement """"""""""""""""""""""" -.. autoclass:: cwlgen.CommandInputArraySchema +.. autoclass:: cwlgen.ShellCommandRequirement :members: :private-members: :special-members: :exclude-members: __weakref__ -.. _requirements: +ResourceRequirement +""""""""""""""""""" -Requirements -============ +.. autoclass:: cwlgen.ResourceRequirement + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ -Requirement -""""""""""" -.. autoclass:: cwlgen.Requirement +Schema +====== + +.. autoclass:: cwlgen.SchemaDefRequirement :members: :private-members: :special-members: - :exclude-members: __weakref__ + :exclude-members: InputRecordSchema,InputEnumSchema,InputArraySchema,__weakref__ -InlineJavascriptReq -""""""""""""""""""" -.. autoclass:: cwlgen.InlineJavascriptReq +Workflow Input Schema +""""""""""""""""""""" + +.. autoclass:: cwlgen.SchemaDefRequirement.InputRecordSchema :members: :private-members: :special-members: :exclude-members: __weakref__ -DockerRequirement -""""""""""""""""" +.. autoclass:: cwlgen.SchemaDefRequirement.InputEnumSchema + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ -.. autoclass:: cwlgen.DockerRequirement +.. autoclass:: cwlgen.SchemaDefRequirement.InputArraySchema :members: :private-members: :special-members: :exclude-members: __weakref__ +- :class:`CommandLineBinding` + + When listed under inputBinding in the input schema, the term "value" + refers to the the corresponding value in the input object. For binding objects listed in + CommandLineTool.arguments, the term "value" refers to the effective value after evaluating valueFrom. + + Import CWL ========== diff --git a/doc/source/commandlinetoolclasses.rst b/doc/source/commandlinetoolclasses.rst new file mode 100644 index 0000000..74bac7d --- /dev/null +++ b/doc/source/commandlinetoolclasses.rst @@ -0,0 +1,81 @@ +.. python-cwlgen - Python library for manipulation and generation of CWL tools. + +*************************** +CommandLineTool API classes +*************************** + +CommandLineTool +=============== + +.. autoclass:: cwlgen.CommandLineTool + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + + +Input and outputs +================= + +CommandInputParameter +""""""""""""""""""""" + +.. autoclass:: cwlgen.CommandInputParameter + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +CommandOutputParameter +"""""""""""""""""""""" + +.. autoclass:: cwlgen.CommandOutputParameter + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +CommandLineBinding +"""""""""""""""""" + +.. autoclass:: cwlgen.CommandLineBinding + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +CommandOutputBinding +"""""""""""""""""""" + +.. autoclass:: cwlgen.CommandOutputBinding + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +Special Types +============== + +.. autoclass:: cwlgen.CommandInputRecordSchema + :members: + :private-members: + :special-members: + :exclude-members: CommandInputRecordField,__weakref__ + +.. autoclass:: cwlgen.CommandInputRecordSchema.CommandInputRecordField + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +.. autoclass:: cwlgen.CommandInputArraySchema + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +.. autoclass:: cwlgen.CommandInputEnumSchema + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst index 078a57c..16649ae 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -4,12 +4,49 @@ Welcome to python-cwlgen's documentation! ========================================= +.. image:: https://travis-ci.org/common-workflow-language/python-cwlgen.svg?branch=master&style=flat + :target: https://travis-ci.org/common-workflow-language/python-cwlgen + :alt: Travis Build Status + +.. image:: https://readthedocs.org/projects/python-cwlgen/badge/?version=latest + :target: https://python-cwlgen.readthedocs.io/en/latest/?badge=latest) + :alt: Documentation + +.. image:: https://badge.fury.io/py/cwlgen.svg + :target: https://pypi.org/project/cwlgen/ + :alt: Pypi module + +.. image:: https://codecov.io/gh/common-workflow-language/python-cwlgen/branch/master/graph/badge.svg + :target: https://codecov.io/gh/common-workflow-language/python-cwlgen + :alt: Code Coverage + + +Python-cwlgen is a python library for the programmatic generation of CWL v1.0. +It supports the generation of CommandLineTool and Workflows. + +The library works for both Python 2.7.12+ and 3.6.0+. + +Quick-start +=========== + +You can install Python-CWLGen through pip with the following command: + +.. code-block:: bash + + pip install cwlgen + +The classes very closely (if not exactly) mirror the CWL v1.0 specification. You can find +more about their parameters in the following specifications: + +- :class:`cwlgen.CommandLineTool` +- :class:`cwlgen.Workflow` + + Python-cwlgen ============= .. toctree:: :maxdepth: 2 - introduction installation user_guide references @@ -17,9 +54,11 @@ Python-cwlgen Python-cwlgen API documentation =============================== .. toctree:: - :maxdepth: 2 + :maxdepth: 1 classes + commandlinetoolclasses + workflowclasses changelogs .. diff --git a/doc/source/installation.rst b/doc/source/installation.rst index b47aac5..299bc13 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -18,10 +18,14 @@ Installation python-cwlgen dependencies ========================== -python-cwlgen is initially built with Python3 and uses the following libraries: +python-cwlgen has been primarily tested using Python3 and uses the following libraries: + +- ``ruamel.yaml`` (between 0.12.4 and 0.15.87) +- ``six`` (1.10.0) + +The project has been designed to work with Python 2.7+ and has accompanying tests, however +please raise an issue if you have incompatibility issues. -- ruamel.yaml (between 0.12.4 and 0.15.87) -- six (1.10.0) .. _installation: @@ -60,7 +64,7 @@ You can remove python-cwlgen with the following command: .. code-block:: bash - pip uninstall python-cwlgen + pip uninstall cwlgen .. Note:: This will not uninstall dependencies. To do so you can make use of `pip-autoremove`_. diff --git a/doc/source/introduction.rst b/doc/source/introduction.rst deleted file mode 100644 index 2a46079..0000000 --- a/doc/source/introduction.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. python-cwlgen - Python library for manipulation and generation of CWL tools. - -.. _introduction: - -************ -Introduction -************ - -Python-cwlgen is a python library for the generation of CWL programmatically. -It supports the generation of CommandLineTool, Workflow and DockerRequirement. diff --git a/doc/source/workflowclasses.rst b/doc/source/workflowclasses.rst new file mode 100644 index 0000000..a7ae1cf --- /dev/null +++ b/doc/source/workflowclasses.rst @@ -0,0 +1,44 @@ +.. python-cwlgen - Python library for manipulation and generation of CWL tools. + +.. _classes: + +******************** +Workflow API classes +******************** + +.. _CWLGen - Workflow: + + +CWL Workflow +============ + +Workflow +"""""""" + +.. autoclass:: cwlgen.workflow.Workflow + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + + +Inputs and Outputs +================== + +InputParameter +"""""""""""""" + +.. autoclass:: cwlgen.workflow.InputParameter + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ + +WorkflowStep +"""""""""""" + +.. autoclass:: cwlgen.workflow.WorkflowStep + :members: + :private-members: + :special-members: + :exclude-members: __weakref__ \ No newline at end of file diff --git a/setup.py b/setup.py index 9d39aee..6e707d0 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,24 @@ from setuptools import setup -exec(open('cwlgen/version.py').read()) +exec(open("cwlgen/version.py").read()) -setup(name="cwlgen", - version=__version__, - description='Generation of CWL programmatically. Available types: Workflow, CommandLineTool and Requirements', - author='Kenzo-Hugo Hillion and Herve Menager', - author_email='kehillio@pasteur.fr', - long_description=open("./README.md").read(), - long_description_content_type="text/markdown", - license='MIT', - keywords=['cwl'], - install_requires=['ruamel.yaml >= 0.12.4, <= 0.15.87'], - packages=["cwlgen"], - classifiers=[ - 'Development Status :: 4 - Beta', - 'Topic :: Scientific/Engineering :: Bio-Informatics', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'Environment :: Console', - ], - ) +setup( + name="cwlgen", + version=__version__, + description="Generation of CWL programmatically. Available types: Workflow, CommandLineTool and Requirements", + author="Kenzo-Hugo Hillion and Herve Menager", + author_email="kehillio@pasteur.fr", + long_description=open("./README.md").read(), + long_description_content_type="text/markdown", + license="MIT", + keywords=["cwl"], + install_requires=["ruamel.yaml >= 0.12.4, <= 0.15.87"], + packages=["cwlgen"], + classifiers=[ + "Development Status :: 4 - Beta", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Environment :: Console", + ], +)