Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky-update #765

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pydra/engine/tests/test_boutiques.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

@no_win
@need_bosh_docker
@pytest.mark.flaky(reruns=3) # need for travis
@pytest.mark.flaky(max_runs=3) # need for travis
@pytest.mark.parametrize(
"maskfile", ["test_brain.nii.gz", "test_brain", "test_brain.nii"]
)
Expand All @@ -45,7 +45,7 @@ def test_boutiques_1(maskfile, plugin, results_function, tmpdir, data_tests_dir)

@no_win
@need_bosh_docker
@pytest.mark.flaky(reruns=3)
@pytest.mark.flaky(max_runs=3)
def test_boutiques_spec_1(data_tests_dir):
"""testing spec: providing input/output fields names"""
btask = BoshTask(
Expand All @@ -70,7 +70,7 @@ def test_boutiques_spec_1(data_tests_dir):

@no_win
@need_bosh_docker
@pytest.mark.flaky(reruns=3)
@pytest.mark.flaky(max_runs=3)
def test_boutiques_spec_2(data_tests_dir):
"""testing spec: providing partial input/output fields names"""
btask = BoshTask(
Expand All @@ -93,7 +93,7 @@ def test_boutiques_spec_2(data_tests_dir):

@no_win
@need_bosh_docker
@pytest.mark.flaky(reruns=3)
@pytest.mark.flaky(max_runs=3)
@pytest.mark.parametrize(
"maskfile", ["test_brain.nii.gz", "test_brain", "test_brain.nii"]
)
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_boutiques_wf_1(maskfile, plugin, tmpdir, infile):

@no_win
@need_bosh_docker
@pytest.mark.flaky(reruns=3)
@pytest.mark.flaky(max_runs=3)
@pytest.mark.xfail(reason="issues with bosh for 4472771")
@pytest.mark.parametrize(
"maskfile", ["test_brain.nii.gz", "test_brain", "test_brain.nii"]
Expand Down
34 changes: 16 additions & 18 deletions pydra/engine/tests/test_node_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import typing as ty
import numpy as np
import time
from unittest import mock
from pathlib import Path
import pytest
import time
from fileformats.generic import File
from fileformats.generic import BinaryFile
import pydra.mark

from .utils import (
Expand Down Expand Up @@ -360,7 +358,7 @@ def test_odir_init():
# Tests for tasks without state (i.e. no splitter)


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_nostate_1(plugin_dask_opt, tmp_path):
"""task without splitter"""
nn = fun_addtwo(name="NA", a=3)
Expand Down Expand Up @@ -401,7 +399,7 @@ def test_task_nostate_1_call():
assert nn.output_dir.exists()


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_nostate_1_call_subm(plugin_dask_opt, tmp_path):
"""task without splitter"""
nn = fun_addtwo(name="NA", a=3)
Expand All @@ -419,7 +417,7 @@ def test_task_nostate_1_call_subm(plugin_dask_opt, tmp_path):
assert nn.output_dir.exists()


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_nostate_1_call_plug(plugin_dask_opt, tmp_path):
"""task without splitter"""
nn = fun_addtwo(name="NA", a=3)
Expand Down Expand Up @@ -551,7 +549,7 @@ def test_task_nostate_7():
# Testing caching for tasks without states


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_nostate_cachedir(plugin_dask_opt, tmp_path):
"""task with provided cache_dir using pytest tmp_path"""
cache_dir = tmp_path / "test_task_nostate"
Expand All @@ -568,7 +566,7 @@ def test_task_nostate_cachedir(plugin_dask_opt, tmp_path):
assert results.output.out == 5


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_nostate_cachedir_relativepath(tmp_path, plugin_dask_opt):
"""task with provided cache_dir as relative path"""
os.chdir(tmp_path)
Expand All @@ -589,7 +587,7 @@ def test_task_nostate_cachedir_relativepath(tmp_path, plugin_dask_opt):
shutil.rmtree(cache_dir)


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_nostate_cachelocations(plugin_dask_opt, tmp_path):
"""
Two identical tasks with provided cache_dir;
Expand Down Expand Up @@ -731,7 +729,7 @@ def test_task_nostate_cachelocations_updated(plugin, tmp_path):
# Tests for tasks with states (i.e. with splitter)


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
@pytest.mark.parametrize("input_type", ["list", "array"])
def test_task_state_1(plugin_dask_opt, input_type, tmp_path):
"""task with the simplest splitter"""
Expand Down Expand Up @@ -1076,7 +1074,7 @@ def test_task_state_6a(plugin, tmp_path):
assert odir.exists()


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_state_comb_1(plugin_dask_opt, tmp_path):
"""task with the simplest splitter and combiner"""
nn = fun_addtwo(name="NA").split(a=[3, 5], splitter="a").combine(combiner="a")
Expand Down Expand Up @@ -1453,7 +1451,7 @@ def test_task_state_comb_contdim_2(tmp_path):
# Testing caching for tasks with states


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_task_state_cachedir(plugin_dask_opt, tmp_path):
"""task with a state and provided cache_dir using pytest tmp_path"""
cache_dir = tmp_path / "test_task_nostate"
Expand Down Expand Up @@ -1606,30 +1604,30 @@ def test_task_files_cachelocations(plugin_dask_opt, tmp_path):
assert not nn2.output_dir.exists()


class OverriddenContentsFile(File):
class OverriddenContentsFile(BinaryFile):
"""A class for testing purposes, to that enables you to override the contents
of the file to allow you to check whether the persistent cache is used."""

def __init__(
self,
fspaths: ty.Iterator[Path],
contents: ty.Optional[bytes] = None,
metadata: ty.Dict[str, ty.Any] = None,
metadata: ty.Optional[ty.Dict[str, ty.Any]] = None,
):
super().__init__(fspaths, metadata=metadata)
self._contents = contents

def byte_chunks(self, **kwargs) -> ty.Generator[ty.Tuple[str, bytes], None, None]:
def byte_chunks(self, **kwargs) -> ty.Generator[ty.Tuple[str, ty.Iterator[bytes]], None, None]: # type: ignore[override]
if self._contents is not None:
yield (str(self.fspath), iter([self._contents]))
else:
yield from super().byte_chunks(**kwargs)

@property
def contents(self):
def raw_contents(self) -> bytes: # type: ignore[override]
if self._contents is not None:
return self._contents
return super().contents
return super().raw_contents


def test_task_files_persistentcache(tmp_path):
Expand All @@ -1645,7 +1643,7 @@ def test_task_files_persistentcache(tmp_path):

@pydra.mark.task
def read_contents(x: OverriddenContentsFile) -> bytes:
return x.contents
return x.raw_contents

assert (
read_contents(x=test_file, cache_dir=cache_dir)(plugin="serial").output.out
Expand Down
6 changes: 3 additions & 3 deletions pydra/engine/tests/test_shelltask.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
pytest.skip("SLURM not available in windows", allow_module_level=True)


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
@pytest.mark.parametrize("results_function", [result_no_submitter, result_submitter])
def test_shell_cmd_1(plugin_dask_opt, results_function, tmp_path):
"""simple command, no arguments"""
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_shell_cmd_2b(plugin, results_function, tmp_path):
# tests with State


@pytest.mark.flaky(reruns=2)
@pytest.mark.flaky(max_runs=2)
def test_shell_cmd_3(plugin_dask_opt, tmp_path):
"""commands without arguments
splitter = executable
Expand Down Expand Up @@ -2174,7 +2174,7 @@ def test_shell_cmd_inputspec_copyfile_state_1(plugin, results_function, tmp_path
# customised input_spec in Workflow


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_wf_shell_cmd_2(plugin_dask_opt, tmp_path):
"""a workflow with input with defined output_file_template (str)
that requires wf.lzin
Expand Down
10 changes: 5 additions & 5 deletions pydra/engine/tests/test_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_wf_in_wf(plugin, tmpdir):
assert res.output.out == 7


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_wf2(plugin_dask_opt, tmpdir):
"""workflow as a node
workflow-node with one task and no splitter
Expand All @@ -156,7 +156,7 @@ def test_wf2(plugin_dask_opt, tmpdir):
assert res.output.out == 3


@pytest.mark.flaky(reruns=2) # when dask
@pytest.mark.flaky(max_runs=2) # when dask
def test_wf_with_state(plugin_dask_opt, tmpdir):
wf = Workflow(name="wf_with_state", input_spec=["x"])
wf.add(sleep_add_one(name="taska", x=wf.lzin.x))
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_slurm_wf_state(tmpdir):


@need_slurm
@pytest.mark.flaky(reruns=3)
@pytest.mark.flaky(max_runs=3)
def test_slurm_max_jobs(tmpdir):
wf = Workflow("new_wf", input_spec=["x", "y"], cache_dir=tmpdir)
wf.inputs.x = 5
Expand Down Expand Up @@ -338,7 +338,7 @@ def cancel(job_name_part):
return proc.stderr.decode("utf-8").strip()


@pytest.mark.flaky(reruns=1)
@pytest.mark.flaky(max_runs=1)
@need_slurm
def test_slurm_cancel_rerun_1(tmpdir):
"""testing that tasks run with slurm is re-queue
Expand Down Expand Up @@ -371,7 +371,7 @@ def test_slurm_cancel_rerun_1(tmpdir):
assert script_dir.exists()


@pytest.mark.flaky(reruns=1)
@pytest.mark.flaky(max_runs=1)
@need_slurm
def test_slurm_cancel_rerun_2(tmpdir):
"""testing that tasks run with slurm that has --no-requeue
Expand Down
Loading
Loading