pytest_wdl.executors package

Submodules

pytest_wdl.executors.cromwell module

class pytest_wdl.executors.cromwell.CromwellExecutor(search_paths: Sequence[pathlib.Path], import_dirs: Optional[List[pathlib.Path]] = None, java_bin: Union[str, pathlib.Path, None] = None, java_args: Optional[str] = None, cromwell_jar_file: Union[str, pathlib.Path, None] = None, cromwell_config_file: Union[str, pathlib.Path, None] = None, cromwell_args: Optional[str] = None)[source]

Bases: pytest_wdl.core.Executor

Manages the running of WDL workflows using Cromwell.

Parameters
  • search_paths – The root path(s) to which non-absolute WDL script paths are relative.

  • import_dirs – Relative or absolute paths to directories containing WDL scripts that should be available as imports.

  • java_bin – Path to the java executable.

  • java_args – Default Java arguments to use; can be overidden by passing java_args=… to run_workflow.

  • cromwell_jar_file – Path to the Cromwell JAR file.

  • cromwell_args – Default Cromwell arguments to use; can be overridden by passing cromwell_args=… to run_workflow.

static get_cromwell_outputs(output)[source]
run_workflow(wdl_script: Union[str, pathlib.Path], workflow_name: Optional[str] = None, inputs: Optional[dict] = None, expected: Optional[dict] = None, **kwargs) → dict[source]

Run a WDL workflow on given inputs, and check that the output matches given expected values.

Parameters
  • wdl_script – The WDL script to execute.

  • workflow_name – The name of the workflow in the WDL script. If None, the name of the WDL script is used (without the .wdl extension).

  • inputs – Object that will be serialized to JSON and provided to Cromwell as the workflow inputs.

  • expected – Dict mapping output parameter names to expected values.

  • kwargs

    Additional keyword arguments, mostly for debugging: * inputs_file: Path to the Cromwell inputs file to use. Inputs are

    written to this file only if it doesn’t exist.

    • imports_file: Path to the WDL imports file to use. Imports are

      written to this file only if it doesn’t exist.

    • java_args: Additional arguments to pass to Java runtime.

    • cromwell_args: Additional arguments to pass to cromwell run.

Returns

Dict of outputs.

Raises
  • Exception – if there was an error executing Cromwell

  • AssertionError – if the actual outputs don’t match the expected outputs

Module contents

pytest_wdl.executors.get_workflow(search_paths: Sequence[pathlib.Path], wdl_file: Union[str, pathlib.Path], workflow_name: Optional[str] = None) → Tuple[pathlib.Path, str][source]

Resolve the WDL file and workflow name.

TODO: if workflow_name is None, parse the WDL file and extract the name

of the workflow.

Parameters
  • search_paths – The root directory(s) to which wdl_file might be relative.

  • wdl_file – Path to the WDL file.

  • workflow_name – The workflow name; if None, the filename without “.wdl” extension is used.

Returns

A tuple (wdl_path, workflow_name)

pytest_wdl.executors.get_workflow_imports(import_dirs: Optional[List[pathlib.Path]] = None, imports_file: Optional[pathlib.Path] = None) → pathlib.Path[source]

Creates a ZIP file with all WDL files to be imported.

Parameters
  • import_dirs – Directories from which to import WDL files.

  • imports_file – Text file naming import directories/files - one per line.

Returns

Path to the ZIP file.

pytest_wdl.executors.get_workflow_inputs(workflow_name: str, inputs_dict: Optional[dict] = None, inputs_file: Optional[pathlib.Path] = None) → Tuple[dict, pathlib.Path][source]

Persist workflow inputs to a file, or load workflow inputs from a file.

Parameters
  • workflow_name – Name of the workflow; used to prefix the input parameters when creating the inputs file from the inputs dict.

  • inputs_dict – Dict of input names/values.

  • inputs_file – JSON file with workflow inputs.

Returns

A tuple (inputs_dict, inputs_file)

pytest_wdl.executors.make_serializable(value)[source]

Convert a primitive, DataFile, Sequence, or Dict to a JSON-serializable object. Currently, arbitrary objects can be serialized by implementing an as_dict() method, otherwise they are converted to strings.

Parameters

value – The value to make serializable.

Returns

The serializable value.