API classes

Workflow and CommandLineTool

See the links below to the CommandLineTool and Workflow classes:

Requirements

Requirement

This is the (abstract) base requirement class.

class cwlgen.Requirement(req_class)[source]
__hash__()[source]

Return hash(self).

__init__(req_class)[source]
Parameters:req_class (STRING) – requirement class
ignore_fields_on_parse = ['class']

Requirement that must be met in order to execute the process.

InlineJavascriptRequirement

class cwlgen.InlineJavascriptRequirement(expression_lib=None)[source]

Indicates that the workflow platform must support inline Javascript expressions. If this requirement is not present, the workflow platform must not perform expression interpolatation.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#InlineJavascriptRequirement

__init__(expression_lib=None)[source]
Parameters:expression_lib (list[STRING]) – List of Strings

SchemaDefRequirement

See the Schema section Below:

SubworkflowFeatureRequirement

class cwlgen.SubworkflowFeatureRequirement[source]

Indicates that the workflow platform must support nested workflows in the run field of WorkflowStep.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#SubworkflowFeatureRequirement

__init__()[source]
Parameters:req_class (STRING) – requirement class

ScatterFeatureRequirement

class cwlgen.ScatterFeatureRequirement[source]

Indicates that the workflow platform must support the scatter and scatterMethod fields of WorkflowStep.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#ScatterFeatureRequirement

__init__()[source]
Parameters:req_class (STRING) – requirement class

MultipleInputFeatureRequirement

class cwlgen.MultipleInputFeatureRequirement[source]

Indicates that the workflow platform must support multiple inbound data links listed in the source field of WorkflowStepInput.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#MultipleInputFeatureRequirement

__init__()[source]
Parameters:req_class (STRING) – requirement class

StepInputExpressionRequirement

class cwlgen.StepInputExpressionRequirement[source]

Indicate that the workflow platform must support the valueFrom field of WorkflowStepInput.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#StepInputExpressionRequirement

__init__()[source]
Parameters:req_class (STRING) – requirement class

DockerRequirement

class cwlgen.DockerRequirement(docker_pull=None, docker_load=None, docker_file=None, docker_import=None, docker_image_id=None, docker_output_dir=None)[source]

Indicates that a workflow component should be run in a Docker container, and specifies how to fetch or build the image.

Documentation: https://www.commonwl.org/v1.0/CommandLineTool.html#DockerRequirement

__init__(docker_pull=None, docker_load=None, docker_file=None, docker_import=None, docker_image_id=None, docker_output_dir=None)[source]
Parameters:
  • docker_pull (STRING) – image to retrive with docker pull
  • docker_load (STRING) – HTTP URL from which to download Docker image
  • docker_file (STRING) – supply the contents of a Dockerfile
  • docker_import (STRING) – HTTP URL to download and gunzip a Docker images
  • docker_image_id (STRING) – Image id for docker run
  • docker_output_dir (STRING) – designated output dir inside the Docker container

SoftwareRequirement

class cwlgen.SoftwareRequirement(packages=None)[source]

A list of software packages that should be configured in the environment of the defined process.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#SoftwareRequirement

__init__(packages=None)[source]
Parameters:req_class (STRING) – requirement class
class cwlgen.SoftwareRequirement.SoftwarePackage(package, version=None, specs=None)

Documentation: https://www.commonwl.org/v1.0/Workflow.html#SoftwarePackage

__init__(package, version=None, specs=None)
Parameters:
  • package – The name of the software to be made available. If the name is common, inconsistent, or otherwise ambiguous it should be combined with one or more identifiers in the specs field
  • version – The (optional) versions of the software that are known to be compatible.
  • specs – One or more IRIs identifying resources for installing or enabling the software in ‘package’

InitialWorkDirRequirement

class cwlgen.InitialWorkDirRequirement(listing)[source]

Define a list of files and subdirectories that must be created by the workflow platform in the designated output directory prior to executing the command line tool.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#InitialWorkDirRequirement

__init__(listing)[source]
Parameters:listing (array<File | Directory | Dirent | string | Expression> | string | Expression) – The list of files or subdirectories that must be placed in the designated output directory prior to executing the command line tool.
class cwlgen.InitialWorkDirRequirement.Dirent(entry, entryname=None, writable=None)

Define a file or subdirectory that must be placed in the designated output directory prior to executing the command line tool. May be the result of executing an expression, such as building a configuration file from a template.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#Dirent

__init__(entry, entryname=None, writable=None)

Initialize self. See help(type(self)) for accurate signature.

EnvVarRequirement

class cwlgen.EnvVarRequirement(env_def)[source]

Define a list of environment variables which will be set in the execution environment of the tool. See EnvironmentDef for details.

Documentation: https://www.commonwl.org/v1.0/CommandLineTool.html#EnvVarRequirement

__init__(env_def)[source]
Parameters:env_def (list[EnvironmentDef]) – The list of environment variables.
class cwlgen.EnvVarRequirement.EnvironmentDef(env_name, env_value)

Define an environment variable that will be set in the runtime environment by the workflow platform when executing the command line tool. May be the result of executing an expression, such as getting a parameter from input.

Documentation: https://www.commonwl.org/v1.0/CommandLineTool.html#EnvironmentDef

__init__(env_name, env_value)
Parameters:
  • env_name (STRING) – The environment variable name
  • env_value (STRING) – The environment variable value

ShellCommandRequirement

class cwlgen.ShellCommandRequirement[source]

Modify the behavior of CommandLineTool to generate a single string containing a shell command line.

Documentation: https://www.commonwl.org/v1.0/CommandLineTool.html#ShellCommandRequirement

__init__()[source]
Parameters:req_class (STRING) – requirement class

ResourceRequirement

class cwlgen.ResourceRequirement(cores_min=None, cores_max=None, ram_min=None, ram_max=None, tmpdir_min=None, tmpdir_max=None, outdir_min=None, outdir_max=None)[source]

Specify basic hardware resource requirements.

Documentation: https://www.commonwl.org/v1.0/CommandLineTool.html#ResourceRequirement

__init__(cores_min=None, cores_max=None, ram_min=None, ram_max=None, tmpdir_min=None, tmpdir_max=None, outdir_min=None, outdir_max=None)[source]
Parameters:
  • cores_min (string | float | None) – Minimum reserved number of CPU cores
  • cores_max (string | float | None) – Maximum reserved number of CPU cores
  • ram_min (string | float | None) – Minimum reserved RAM in mebibytes (2**20)
  • ram_max (string | float | None) – Maximum reserved RAM in mebibytes (2**20)
  • tmpdir_min (string | float | None) – Minimum reserved filesystem based storage for the designated temporary directory, in mebibytes (2**20)
  • tmpdir_max (string | float | None) – Maximum reserved filesystem based storage for the designated temporary directory, in mebibytes (2**20)
  • outdir_min (string | float | None) – Minimum reserved filesystem based storage for the designated output directory, in mebibytes (2**20)
  • outdir_max (string | float | None) – Maximum reserved filesystem based storage for the designated output directory, in mebibytes (2**20)

Schema

class cwlgen.SchemaDefRequirement(types)[source]

This field consists of an array of type definitions which must be used when interpreting the inputs and outputs fields. When a type field contain a IRI, the implementation must check if the type is defined in schemaDefs and use that definition. If the type is not found in schemaDefs, it is an error. The entries in schemaDefs must be processed in the order listed such that later schema definitions may refer to earlier schema definitions.

Documentation: https://www.commonwl.org/v1.0/Workflow.html#SchemaDefRequirement

__init__(types)[source]
Parameters:types (list[InputRecordSchema | InputEnumSchema | InputArraySchema]) – The list of type definitions.

Workflow Input Schema

class cwlgen.SchemaDefRequirement.InputRecordSchema(label=None, name=None)

Documentation: https://www.commonwl.org/v1.0/Workflow.html#InputRecordSchema

class InputRecordField(name, type, doc=None, input_binding=None, label=None)

Documentation: https://www.commonwl.org/v1.0/Workflow.html#InputRecordField

__init__(name, type, doc=None, input_binding=None, label=None)
Parameters:
  • name
  • input_type (CWLType | InputRecordSchema | InputEnumSchema | InputArraySchema | string | array<CWLType | InputRecordSchema | InputEnumSchema | InputArraySchema | string>) –
  • doc – A documentation string for this field
  • input_binding (CommandLineBinding) –
  • label
__init__(label=None, name=None)
Parameters:
  • fields (array<InputRecordField>) – Defines the fields of the record.
  • label – A short, human-readable label of this object.
  • name – NF (Name of the InputRecord)
class cwlgen.SchemaDefRequirement.InputEnumSchema(symbols, label=None, name=None, input_binding=None)

Documentation: https://www.commonwl.org/v1.0/Workflow.html#InputEnumSchema

__init__(symbols, label=None, name=None, input_binding=None)
Parameters:
  • symbols (list[STRING]) – Defines the set of valid symbols.
  • label (STRING) – A short, human-readable label of this object.
  • name (STRING) –
  • input_binding (CommandLineBinding) –
class cwlgen.SchemaDefRequirement.InputArraySchema(items, label=None, input_binding=None)

Documentation: https://www.commonwl.org/v1.0/Workflow.html#InputArraySchema

__init__(items, label=None, input_binding=None)
Parameters:
  • items (CWLType | InputRecordSchema | InputEnumSchema | InputArraySchema | string | array<CWLType | InputRecordSchema | InputEnumSchema | InputArraySchema | string>) – Defines the type of the array elements.
  • label (STRING) – A short, human-readable label of this object.
  • input_binding (CommandLineBinding) –
  • 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

As of release v0.3.0 the existing importing CWL has been replaced by an automated deserialization. Each function that inherits from the Serializable class will have a parse_dict method.

If you’re adding a class and want to provide a hint on how to parse a particular field, you can add a static parse_types dictionary onto your class with the fieldname and a list of types that you want to try and parse as. If your input can be a list (eg: T[]), or a dictionary with the identifier as the key (eg: { $identifier: T }, you can let your type be [T] in the parse_types dict. It will automatically inject this identifier in the constructor. See the Serializable.parse_dict class for more information.

class Workflow:
    parse_types = {
        # Parse inputs as : [InputParameter] or { id: InputParameter }
        "inputs": [[InputParameter]],

        # will attempt to parse extraParam as a string, then SecondaryType,
        # then (TertiaryType[] || { $identifier: TertiaryType }
        "extraParam": [str, SecondaryType, [TertiaryType]]
    }
cwlgen.parse_cwl(cwl_path)[source]

Method that parses a CWL file and will a cwlgen.Workflow or cwlgen.CommandLineTool. Note: this will not import additional files.

Parameters:cwl_path (str) – PATH to the CWL file
Returns:cwlgen.Workflow | cwlgen.CommandLineTool
cwlgen.parse_cwl_dict(cwl_dict)[source]

Method that parses a dictionary and will return a cwlgen.Workflow or cwlgen.CommandLineTool.

Parameters:cwl_dict (dict) – The dictionary to pass, must contain a ‘class’ field.
Returns:cwlgen.Workflow | cwlgen.CommandLineTool