Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #24 from illusional/v0.3.0-release
Browse files Browse the repository at this point in the history
V0.3.0 release
  • Loading branch information
illusional authored Jul 5, 2019
2 parents d322635 + 8448470 commit e88fa2d
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 123 deletions.
116 changes: 82 additions & 34 deletions cwlgen/commandlinetool.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@


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
place it in the contents field
: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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -174,19 +222,19 @@ 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():
d["s:" + key] = value
# - 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):
Expand All @@ -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()
4 changes: 2 additions & 2 deletions cwlgen/version.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions doc/source/changelogs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
====

Expand Down
Loading

0 comments on commit e88fa2d

Please sign in to comment.