Skip to main content

Helper to generate cwl workflows

Project description

graph2cwl

Python module that interfaces with cwl-utils in order to generate cwl files.

Getting Started

pip install graph2cwl

Here is a code snippet :

from graph2cwl import WorkflowCreator

wf = WorkflowCreator(id="wf")
wf.add_step(id="step_1", run="./my_file.py")
wf.add_step(id="step_2", run="./my_file_2.py")
wf.add_dependency("step_1", "step_2", dep_name="step_1_out")
wf.add_workflow_input("input_1")
wf.add_workflow_output("output", outputSource="step_1/step_1_out")
wf.add_dependency("input_1", "step_2")
wf.add_dependency("input_1", "step_1")

wf.to_yaml("wf.yaml")

This creates the following valid cwl:

id: w
class: Workflow
inputs:
  - id: input_1
    type: File
outputs:
  - id: output
    outputSource: step_1/step_1_out
    type: File
cwlVersion: v1.2
steps:
  - id: step_1
    in:
      - id: xehsftvk
        source: input_1
    out:
      - step_1_out
    run: my_file.py
  - id: step_2
    in:
      - id: fwfmzpkk
        source: step_1/step_1_out
      - id: ellhmrzg
        source: input_1
    out: []
    run: my_file_2.py

which can be visualized (see cwl2nx):

• w/input_1
├─• w/step_1
│ ╰─• w/step_1/step_1_out
│   ├─• w/output
╰───┴─• w/step_2

Advanced usage

To embed the cwl with additionnal information, you must follow the cwl specification, implemented in cwl-utils. For example, to insert additional informations to a step, you can add the hints argument, or the extension_field one :

from graph2cwl import WorkflowCreator

wf = WorkflowCreator(id="w")
wf.add_step(id="step_1", run="./my_file.py", hints={"hint1": "value1"})
wf.add_step(id="step_2", run="./my_file_2.py")
wf.add_dependency("step_1", "step_2", dep_name="step_1_out")
wf.add_workflow_input("input_1", extension_fields={"additional_field": "het"})
wf.add_workflow_output("output", outputSource="step_1/step_1_out")
wf.add_dependency("input_1", "step_2")
wf.add_dependency("input_1", "step_1")

wf.to_yaml("wf2.yaml")

See : https://cwl-utils.readthedocs.io/en/latest/autoapi/cwl_utils/parser/cwl_v1_2/index.html#cwl_utils.parser.cwl_v1_2.WorkflowStep for the list of supported arguments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph2cwl-0.0.2.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file graph2cwl-0.0.2.tar.gz.

File metadata

  • Download URL: graph2cwl-0.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for graph2cwl-0.0.2.tar.gz
Algorithm Hash digest
SHA256 525a82f1c5b6fa6a31e5a3733cc54d5c560def2e7cc878a98de15612a33590c3
MD5 bd27ffc329c9546cdaa0c5df5c588236
BLAKE2b-256 bf4cf489ce1ab19d9cee6ed5baffae08faec5b81a28ec67ac1d5a2416d811723

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page