rabix / cwl-format

A very opinionated code formatter for CWL
Apache License 2.0
9 stars 4 forks source link
code-formatter common-workflow-language cwl

CWL Format

Tests PyPI version

CWL Format is a specification and a reference implementation for a very opinionated CWL code formatter.

It outputs CWL in a standardized YAML format. It has no settings or options because you have better things to do with your time. And because CWL Format is always correct.

This repository lists the formatting rules and also contains a Python implementation of the formatter.

pip install cwlformat
cwl-format unformatted.cwl > formatted.cwl

If you don't have a > py3.6 environment, you can use pipx:

pip install pipx  # from your < py3.6 environment
pipx ensurepath # ensures CLI application directory is on your $PATH
pipx install cwlformat --python python3.7 #tells pipx to set up a Py3.7 env for this app

Use programmatically in Python by doing

from cwlformat.formatter import cwl_format

formatted_text = cwl_format(unformatted_text)

or

from cwlformat.formatter import stringify_dict

as_dict = load_yaml(unformatted_text)
formatted_str = stringify_dict(as_dict)

Rules

Conformance tests

A series of documents are found in the tests directory that can be used to check correctness of a formatter. The files named original-* are the input files and the files named formatted-* are the corresponding formatted documents. There are a mixture of YAML and JSON input files. Formatted files are always YAML.

CWL Exploder

This takes as input a packed workflow (workflow with all steps in lined) and splits it recursively into parts.

cwl-explode formatted-atac-seq-pipeline.cwl expected-exploded-atac-seq.cwl

Results in the exploded parent workflow and 52 sub-components