Skip to main content

Fixtures for pytest for running WDL workflows using Cromwell.

Project description

pytest-wdl

Travis CI Code Coverage Documentation Status

This package is a plugin for the pytest unit testing framework that enables testing of workflows written in Workflow Description Language.

Dependencies

  • Python 3.6+
  • Java 1.8+
  • Cromwell JAR file
  • Docker daemon (if your WDL tasks depend on Docker images)

Other python dependencies are installed when you install the library.

Installation

Install from PyPI

$ pip install pytest-wdl

Install from source

You can to clone the repository and install:

$ make install

Or use pip to install from github:

$ pip install git+https://github.com/elilillyco/pytest-wdl.git

Install optional dependencies

Some optional features of pytest-wdl have additional dependencies that are loaded on-demand. For example, to enable comparison of expected and actual BAM file outputs of a workflow, the pysam library is required.

The following data types require an "extras" installation:

  • bam

To install the dependencies for a data type that has extra dependencies:

$ pip install pytest-wdl[<data_type>]

To do this locally, you can clone the repo and run:

$ pip install -e .[<data_type>]

To install pytest-wdl and all extras dependencies:

$ pip install pytest-wdl[all]

Usage

The pytest-wdl plugin provides a set of fixtures for use with pytest. Here is a quick example:

# test_variant_caller.py
def test_variant_caller(workflow_data, workflow_runner):
    inputs = workflow_data.get_dict("bam", "bai")
    inputs["index"] = {
        "fasta": workflow_data["index_fa"],
        "organism": "human"
    }
    expected = workflow_data.get_dict("vcf")
    workflow_runner(
        "variant_caller/variant_caller.wdl",
        "call_variants",
        inputs,
        expected
    )

This test will execute a workflow (such as the following one) with the specified inputs, and will compare the outputs to the specified expected outputs.

# variant_caller.wdl
version 1.0

struct Index {
  File fasta
  String organism
}

workflow call_variants {
  input {
    File bam
    File bai
    Index index
  }
  ...
  output {
    File vcf = variant_caller.vcf
  }
}

Input and output data are defined in a test_data.json file in the same directory as your test script:

{
  "bam": {
    "url": "http://example.com/my.bam"
  },
  "bai": {
    "url": "http://example.com/my.bam.bai"
  },
  "index_fa": {
    "name": "chr22.fasta"
  },
  "vcf": {
    "url": "http://example.com/expected.vcf.gz",
    "type": "vcf",
    "allowed_diff_lines": 2
  }
}

For details, read the docs.

Development

To develop pytest-wdl, clone the repository and install all the dependencies:

$ git clone https://github.com/EliLillyCo/pytest-wdl.git
$ pip install -r requirements.txt

To run the full build and unit tests, run:

$ make

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

pytest-wdl-0.1.2.dev0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

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

pytest_wdl-0.1.2.dev0-py2.py3-none-any.whl (39.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-wdl-0.1.2.dev0.tar.gz.

File metadata

  • Download URL: pytest-wdl-0.1.2.dev0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pytest-wdl-0.1.2.dev0.tar.gz
Algorithm Hash digest
SHA256 e51f7ac7aef8ac80f3833bb4d2bae4f4986395d1aabe55cba717d8fb714b9a26
MD5 e8487146b661ba6bea63bfcab72b957a
BLAKE2b-256 7fd73cd96ef575f878a28c6c4bf74c9b2003af9e5a2de703913a445e4fcf54cc

See more details on using hashes here.

File details

Details for the file pytest_wdl-0.1.2.dev0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_wdl-0.1.2.dev0-py2.py3-none-any.whl
  • Upload date:
  • Size: 39.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pytest_wdl-0.1.2.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7442582ad1ce71e1f1d864816066100f6ae1de6fb3951d3a59db725fe6ba1f6a
MD5 27d9592392736c9b0be37992c4f367ea
BLAKE2b-256 0f0ab431aa2ad0206a6b8e336d2490f60ec090ad9132629e24787960af17a004

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