Skip to content

Commit 45887cd

Browse files
authored
Merge pull request #105 from LUMC/release1.3.0
Release 1.3.0
2 parents 844740a + 2cccc3e commit 45887cd

31 files changed

+747
-453
lines changed

.travis.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: python
22
install:
33
- pip install tox
44
dist: xenial
5-
python: 3.5 # Use the oldest supported version of python as default.
5+
python: 3.6 # Use the oldest supported version of python as default.
66
script:
77
- tox -e $TOX_ENV
88
matrix:
@@ -11,30 +11,25 @@ matrix:
1111
# Use default python3 version here.
1212
- env: TOX_ENV=docs
1313
- env: TOX_ENV=lint
14-
1514
# UNIT TESTS
1615
# On most recent versions of python.
17-
- python: 3.6
18-
env: TOX_ENV=py36
19-
- python: 3.7
20-
env: TOX_ENV=py37
21-
- python: 3.8
22-
env: TOX_ENV=py38
23-
- python: 3.5
24-
env: TOX_ENV=py35
16+
- env: TOX_ENV=py36
2517
install:
2618
- pip install codecov
2719
- pip install tox
2820
after_success:
2921
- codecov -v # -v to make sure coverage upload works.
22+
- python: 3.7
23+
env: TOX_ENV=py37
24+
- python: 3.8
25+
env: TOX_ENV=py38
3026

3127
# FUNCTIONAL TESTS
32-
- python: 3.6
33-
env: TOX_ENV=snakemake
34-
- python: 3.7
35-
env: TOX_ENV=snakemake
28+
# Use default python here.
29+
- env: TOX_ENV=snakemake
30+
- env: TOX_ENV=miniwdl
3631
- env: TOX_ENV=cromwell
37-
before_install:
32+
install:
3833
# Install conda
3934
- export MINICONDA=${HOME}/miniconda
4035
- export PATH=${MINICONDA}/bin:${PATH}
@@ -44,5 +39,6 @@ matrix:
4439
- conda config --add channels defaults
4540
- conda config --add channels bioconda
4641
- conda config --add channels conda-forge
47-
- conda create -n my_env cromwell tox # Install tox for good integration within the conda env.
42+
# TODO: Upgrade cromwell once https://github.com/broadinstitute/cromwell/pull/5456 is fixed.
43+
- conda create -n my_env cromwell=48 tox # Install tox for good integration within the conda env.
4844
- source activate my_env

HISTORY.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10+
version 1.3.0
11+
---------------------------
12+
Python 3.6 and pytest 5.4.0.0 are now minimum requirements for pytest-workflow.
13+
This was necessary for fixing the deprecation warning issue and the issue with
14+
the subdirectory evaluation. This also gave the opportunity to simplify the
15+
source code using new python 3.6 syntax.
16+
17+
+ Using the ``name`` keyword argument in workflow marks will be deprecated
18+
from 1.4.0 onwards. A warning will be given if this is used. For example:
19+
``pytest.mark.workflow(name="my_workflow")``. Use the name as argument
20+
instead: ``pytest.mark.workflow("my_workflow")``.
21+
+ Allow running custom tests on multiple workflows. You can now use
22+
``pytest.mark.workflow("worflow name 1", "workflow name 2", ...)``.
23+
(`Issue #75 <https://github.com/LUMC/pytest-workflow/issues/75>`_)
24+
+ Add a miniwdl example to the documentation.
25+
+ Added a ``--symlink`` flag to the CLI that changes the copying behavior.
26+
Instead of copying, it creates a similar directory structure where all files
27+
are linked to with symbolic links. (`Issue #96
28+
<https://github.com/LUMC/pytest-workflow/issues/98>`_)
29+
+ Refactored the code base. Python 3.6's f-strings and type annotation were
30+
used consistently throughout the project. Some code was rewritten to be more
31+
concise and readable.
32+
+ Improved speed for searching string content in files. This was achieved by
33+
removing intermediate functions and simplifying the search function.
34+
+ Improved speed for calculating md5sums by increasing the read buffer size
35+
from 8k to 64k.
36+
+ Solve issue where pytest would display a lot of deprecation warnings when
37+
running pytest-workflow. (`Issue #98
38+
<https://github.com/LUMC/pytest-workflow/issues/98>`_)
39+
+ Fix issues with later versions of Cromwell and Snakemake in CI testing.
40+
+ Add correct subdirectory evaluation to fix issue where ``/parent-dir/child``
41+
was evaluated as a subdirectory of ``/parent`` due to starting with the same
42+
string. (`Issue #95 <https://github.com/LUMC/pytest-workflow/issues/95>`_)
43+
+ Fix error in cromwell example which did not allow it to remove folders
44+
correctly.
45+
1046
version 1.2.3
1147
---------------------------
1248
+ Added missing ``help`` section for ``--tag`` on the CLI.

docs/examples.rst

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ created by the same user that runs the test (docker containers run as root by
5555
default). This will ensure that files can be deleted by pytest-workflow
5656
afterwards.
5757

58-
The following yaml file tests a Cromwell pipeline. In this case Cromwell is
59-
installed via conda. The conda installation adds a wrapper to Cromwell so it
60-
can be used as a command, instead of having to use the jar.
58+
The following yaml file tests a WDL pipeline run with Cromwell. In this case
59+
Cromwell is installed via conda. The conda installation adds a wrapper to
60+
Cromwell so it can be used as a command, instead of having to use the jar.
6161

6262
.. code-block:: yaml
6363
@@ -70,3 +70,42 @@ can be used as a command, instead of having to use the jar.
7070
contains:
7171
- "WorkflowSucceededState"
7272
73+
WDL with miniwdl example
74+
------------------------
75+
76+
For miniwdl please consult the `runner reference
77+
<https://miniwdl.readthedocs.io/en/stable/runner_reference.html>`_ for more
78+
information on the localization of output files as well as options to modify
79+
the running of miniwdl from the environment.
80+
81+
Miniwdl will localize all the output files to an ``output_links`` directory
82+
inside the test output directory. If you have a workflow with the output:
83+
84+
.. code-block::
85+
86+
output {
87+
File moo_file = moo_task.out
88+
Array[File] stats = moo_task.stats_files
89+
}
90+
91+
Inside the ``output_links`` directory the directories ``moo_file`` and
92+
``stats`` will be created. Inside these directories will be the produced files.
93+
94+
The following yaml file tests a WDL pipeline run with miniwdl.
95+
96+
.. code-block:: yaml
97+
98+
- name: My pipeline
99+
command: miniwdl run -i inputs.json -d test-output/ moo.wdl
100+
files:
101+
- path: test-output/output_links/moo_file/moo.txt.gz
102+
md5sum: 173fd8023240a8016033b33f42db14a2
103+
- path: test-output/output_links/stats/number_of_moos_per_cow.tsv
104+
contains:
105+
- 42
106+
- path: test-output/output_links/stats/joy_invoking_moos.tsv
107+
must_not_contain:
108+
- 0
109+
110+
Please note that the trailing slash in ``-d test-output/`` is important. It
111+
will ensure the files end up in the ``test-output`` directory.

docs/running_pytest_workflow.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Specific pytest options for pytest workflow
2626
:func: __pytest_workflow_cli
2727
:prog: pytest
2828

29-
Temporary directory cleanup
30-
---------------------------
29+
Temporary directory cleanup and creation
30+
----------------------------------------
3131

3232
The temporary directories are cleaned up after the tests are completed.
3333
If you wish to inspect the output of a failing
@@ -51,6 +51,16 @@ use ``--basetemp <dir>`` to change pytest's base temp directory.
5151
DO NOT use ``--basetemp`` on directories where none of the
5252
contents should be deleted.
5353

54+
The temporary directories created are copies of pytest's root directory, the
55+
directory from which it runs the tests. If you have lots of tests, and if you
56+
have a large repository, this may take a lot of disk space. To alleviate this
57+
you can use the ``--symlink`` flag which will create the same directory layout
58+
but instead symlinks the files instead of copying them. This is *slower* for
59+
lots of small files, and it carries with it the risk that the tests may alter
60+
files from your work directory. If there are a lot of large files and files are
61+
used read-only in tests, then it will use a lot less disk space and be faster
62+
as well.
63+
5464
Running multiple workflows simultaneously
5565
-----------------------------------------
5666

docs/writing_tests.rst

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,34 @@ workflow.
8686
import pathlib
8787
import pytest
8888
89-
@pytest.mark.workflow(name='files containing numbers')
89+
@pytest.mark.workflow('files containing numbers')
9090
def test_div_by_three(workflow_dir):
9191
number_file = pathlib.Path(workflow_dir, "123.txt")
9292
number_file_content = number_file.read_text()
9393
assert int(number_file_content) % 3 == 0
9494
95-
The ``@pytest.mark.workflow(name='files containing numbers')`` marks the test
96-
as belonging to a workflow named ``files containing numbers``. The mark can
97-
also be written without the explicit ``name`` key as
98-
``@pytest.mark.workflow('files containing nummbers')``. This test will only run
99-
if the workflow 'files containing numbers' has run.
95+
The ``@pytest.mark.workflow('files containing numbers')`` marks the test
96+
as belonging to a workflow named ``files containing numbers``. This test will
97+
only run if the workflow 'files containing numbers' has run.
98+
99+
Multiple workflows can use the same custom test like this:
100+
101+
.. code-block:: python
102+
103+
import pathlib
104+
import pytest
105+
106+
@pytest.mark.workflow('my_workflow', 'another_workflow',
107+
'yet_another_workflow')
108+
def test_ensure_long_logs_are_written(workflow_dir):
109+
log = pathlib.Path(workflow_dir, "log.out")
110+
assert len(log.readtext()) > 10000
100111
101112
``workflow_dir`` is a fixture. It does not work without a
102113
``pytest.mark.workflow('workflow_name')`` mark. This is a
103114
`pathlib.Path <https://docs.python.org/3/library/pathlib.html>`_ object that
104-
points to the folder where the named workflow was executed. This allows writing of
105-
advanced python tests for each file produced by the workflow.
115+
points to the folder where the named workflow was executed. This allows writing
116+
of advanced python tests for each file produced by the workflow.
106117

107118
.. note::
108119

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pyyaml
2-
pytest>=4
2+
pytest>=5.4.0
33
jsonschema

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
setup(
2323
name="pytest-workflow",
24-
version="1.2.3",
24+
version="1.3.0",
2525
description="A pytest plugin for configuring workflow/pipeline tests "
2626
"using YAML files",
2727
author="Leiden University Medical Center",
@@ -40,7 +40,6 @@
4040
classifiers=[
4141
"Programming Language :: Python :: 3 :: Only",
4242
"Programming Language :: Python :: 3",
43-
"Programming Language :: Python :: 3.5",
4443
"Programming Language :: Python :: 3.6",
4544
"Programming Language :: Python :: 3.7",
4645
"Programming Language :: Python :: 3.8",
@@ -49,9 +48,10 @@
4948
"GNU Affero General Public License v3 or later (AGPLv3+)",
5049
"Framework :: Pytest",
5150
],
52-
python_requires=">=3.5", # Because we use type annotation.
51+
# Because we use the resolve(strict=False) feature from pathlib.
52+
python_requires=">=3.6",
5353
install_requires=[
54-
"pytest>=4",
54+
"pytest>=5.4.0", # To use from_parent node instantiation.
5555
"pyyaml",
5656
"jsonschema"
5757
],

src/pytest_workflow/__init__.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,3 @@
1313
#
1414
# You should have received a copy of the GNU Affero General Public License
1515
# along with pytest-workflow. If not, see <https://www.gnu.org/licenses/
16-
17-
import re
18-
import shutil
19-
from pathlib import Path
20-
from typing import List
21-
22-
23-
# This function was created to ensure the same conversion is used throughout
24-
# pytest-workflow.
25-
def replace_whitespace(string: str, replace_with: str = '_') -> str:
26-
"""
27-
Replaces all whitespace with the string in replace_with.
28-
:param string: input string
29-
:param replace_with: Replace whitespace with this string. Default: '_'
30-
:return: The string with whitespace converted.
31-
"""
32-
return re.sub(r'\s+', replace_with, string)
33-
34-
35-
def rm_dirs(directories: List[Path]):
36-
for directory in directories:
37-
shutil.rmtree(str(directory))

0 commit comments

Comments
 (0)