Skip to main content

Formatter for WDL files

Project description

wdlfmt — a formatter for Workflow Description Language (WDL)

Status warning

wdlfmt is an opinionated, lossless formatter for WDL v1.0 that enforces consistency and targets the BioWDL Style Guidelines.

For now there is no automated way of styling or checking the style of WDL files according to these guidelines. — BioWDL Style Guidelines

wdlfmt aims to solve this problem.

Installation

git clone https://github.com/Chris1221/wdlfmt.git
pip install -e wdlfmt

Or with pixi:

git clone https://github.com/Chris1221/wdlfmt.git
cd wdlfmt && pixi install

Usage

By default, formatted output is written to stdout and a style compliance checklist is printed to stderr:

wdlfmt my_task.wdl

Format in place with -i:

wdlfmt -i my_task.wdl

Suppress the checklist with --no-check:

wdlfmt --no-check my_task.wdl

Redirect formatted WDL to a file while keeping the checklist visible:

wdlfmt my_task.wdl > formatted.wdl

What the formatter does

wdlfmt rewrites WDL files with consistent style, preserving all comments:

Rule Example (before → after)
4-space indentation tabs / mixed spaces → 4 spaces
Heredoc command syntax command { ... }command <<< ... >>>
Double-quoted strings 'hello'"hello"
Spaces around = key=valuekey = value

BioWDL style compliance checklist

After every format run, wdlfmt emits a per-rule checklist to stderr. Rules the formatter enforces are shown as confirmed guarantees; content rules that depend on the file's naming and structure are checked and reported:

BioWDL Style Guide Compliance
──────────────────────────────────────────────────────
  Formatter guarantees
    ✓  4-space indentation
    ✓  Heredoc (<<<) command syntax
    ✓  Double-quote string literals
    ✓  Spaces around = operator
  Content checks
    ✓  Task names are UpperCamelCase
    ✓  Workflow names are UpperCamelCase
    ✓  Struct names are UpperCamelCase
    ✗  Call aliases are lowerCamelCase
         Non-conforming aliases: myAlias
    ✓  Line length ≤ 100 chars
    !  set -e -o pipefail in multi-command blocks
         Missing in: block 1
    !  parameter_meta section present
         Missing in: task 'MyTask'
    ✓  docker defined in runtime blocks
──────────────────────────────────────────────────────
  1 failed  ·  2 warning(s)  ·  9 passed

Symbols: pass · fail (rule violated) · ! warn (advisory)

Content rules

Rule Level Description
Task names are UpperCamelCase fail task myTask → rename to MyTask
Workflow names are UpperCamelCase fail Same convention for workflows
Struct names are UpperCamelCase fail Same convention for structs
Call aliases are lowerCamelCase fail/warn call Foo as Bar fails; call Foo (no alias) warns
Line length ≤ 100 chars fail Reports offending line numbers
set -e -o pipefail in command blocks warn Advisory for multi-command blocks
parameter_meta section present warn Advisory per task/workflow
docker in runtime blocks warn Advisory per runtime block

Python API

import wdlfmt

# Format a WDL string
formatted = wdlfmt.format_wdl_str(wdl_text)

# Run the style checker on already-formatted text
results = wdlfmt.check_style(formatted)
for r in results:
    print(r.rule, r.status.value, r.details)

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

wdlfmt-0.1.0.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wdlfmt-0.1.0-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

Details for the file wdlfmt-0.1.0.tar.gz.

File metadata

  • Download URL: wdlfmt-0.1.0.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wdlfmt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 197571f560db1d5ec5831ebeb7c1870806646740fa4a15a13827e4fe9e57c3db
MD5 d10aea1283221f8e53cfdae21f2fea37
BLAKE2b-256 416f4c1a0ef42fe377b749ea1dd0b031d936c2316ee08f411b8a0e76c7ea9f99

See more details on using hashes here.

File details

Details for the file wdlfmt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wdlfmt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wdlfmt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b3e50efcdb02c8394e0df82ebf960a7aa0f2ca0efdead0d8356073fca26f1ab
MD5 3d88c36fc5e474b919703108ebf4f93c
BLAKE2b-256 b51f9a7ee90c9f0f341841b9dda7bbdbf4e6ebe8f20b1c991327cbf3f18d46d6

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