Skip to main content

WDL workflow inputs validation

Project description

winval

Workflow inputs validation python library

  • Currently, supports WDL workflows.
  • Constraints on inputs can be written as specially tagged (#@wv) comments in the WDL inputs section.
  • The syntax of constraints is a python-similar DSL, with ANTLR defined grammar.
  • The WDL + inputs.json can be validated using a script/function before submitting a workflow.

Installation:

pip install winval

Usage:

validate_wdl_constraints

From python

from winval.validate_wdl_constraints import run_winval
is_validated = run_winval(wdl_file, json_file)

From unix command-line:

python winval/validate_wdl_constraints.py --wdl <wdl_file> --json <json_file>

cloud_files_validater

Make sure google-storage permissions are equivalent to the batch workers permissions

From python

from winval.cloud_files_validator import CloudFilesValidator
is_validated = CloudFilesValidator(args.wdl, args.json).validate()

From unix command-line:

python winval/cloud_files_validator.py --wdl <wdl_file> --json <json_file>

WDL constraints example

workflow MyWorkflow {

  input {
    File file
    Int c
    File* opt_file_1
    File* opt_file_2
    Array[File] files
    Array[File] index_files
    MyStruct struct_instance

    #@wv defined(opt_file_1) <-> defined(opt_file_2)
    #@wv defined(opt_file_1) -> c > 1
    #@wv len(files) == len(index_files)
    #@wv len(files) >= 0
    #@wv len(index_files) >= 0
    #@wv c <= 1 and c >= 0
    #@wv suffix(file) == ".fasta"
    #@wv suffix(files) <= {".bam", ".cram"} 
    #@wv prefix(index_files) == files
    #@wv len(struct_instance['field_a']) > 0
  }
  ...
}
  
  struct MyStruct{
     String field_a,
     String field_b
  }

Generate parsers from grammar:

cd <project_root>/winval
antlr4 -Dlanguage=Python3 winval.g4 -visitor -o antlr

Available atomic expressions:

  • int: 5
  • float: 5.6
  • bool: True, False
  • str: "some string", 'some_string'
  • workflow_variable: my_var
  • evaluates to value given by json conf, or None if not defined in json
  • empty_set: {}

Available python operators

  • +,-,*,**,/,&,|,%
  • and, or, in
  • <, <=, ==, >=, >, !=
  • Notice the following useful operators work for sets:
    • -: set subtraction
    • &: set intersection
    • | : is set union
    • <=: subset

Available python functions

  • len(), not()
  • basename(), splitext() (from os.path)

Available convenience functions and operators:

  • x <-> y: if-and-only-if logical operator (if x is true if and only if y is true)
  • x -> y: implies logical operator (if x is true then y should be true)
  • defined(x): if x a defined variable
  • prefix(x): return path prefix of String/File or list of prefixes for
  • suffix(x): return path suffix of String/File or set of suffixes for Array[String]/Array[File]

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

winval-0.7.0.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

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

winval-0.7.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file winval-0.7.0.tar.gz.

File metadata

  • Download URL: winval-0.7.0.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.5.0-1015-azure

File hashes

Hashes for winval-0.7.0.tar.gz
Algorithm Hash digest
SHA256 fd510bd74545beb7a9a3243f00387490edb350e5e5bc8b44de234ba45325a70d
MD5 18b82a8640c7069008b497d5a5a7524f
BLAKE2b-256 ac7a9c61b5f9a8c45b073b526a8bdd5e36ce1ce8acc2f47fdf493dc3e207512c

See more details on using hashes here.

File details

Details for the file winval-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: winval-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.5.0-1015-azure

File hashes

Hashes for winval-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f6f6f0c8721900534bdcb51d05fedef133fd2023950b61035e5b2a13446d2ec
MD5 d655a04e5f4558c7ece76c4f54b7201d
BLAKE2b-256 c4f21b47d06a1fc5184f65bb8ed00e6d1e35ae228aa39302f6f296786ed13c83

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