Skip to content

Commit

Permalink
Consolidate dask and mlflow fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Oct 16, 2024
1 parent fe7f2a0 commit ea6b154
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
26 changes: 26 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,32 @@ def openai_fixture(fail_missing: bool):
yield import_or_skip("openai", reason=OPT_DEP_SKIP_REASON.format(package="openai"), fail_missing=fail_missing)


@pytest.fixture(scope='session')
def dask_distributed(fail_missing: bool):
"""
Mark tests requiring dask.distributed
"""
yield import_or_skip("dask.distributed",
reason=OPT_DEP_SKIP_REASON.format(package="dask.distributed"),
fail_missing=fail_missing)


@pytest.fixture(scope='session')
def dask_cuda(fail_missing: bool):
"""
Mark tests requiring dask_cuda
"""
yield import_or_skip("dask_cuda", reason=OPT_DEP_SKIP_REASON.format(package="dask_cuda"), fail_missing=fail_missing)


@pytest.fixture(scope='session')
def mlflow(fail_missing: bool):
"""
Mark tests requiring mlflow
"""
yield import_or_skip("mlflow", reason=OPT_DEP_SKIP_REASON.format(package="mlflow"), fail_missing=fail_missing)


@pytest.fixture(name="langchain", scope='session')
def langchain_fixture(fail_missing: bool):
"""
Expand Down
7 changes: 3 additions & 4 deletions tests/examples/ransomware_detection/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import yaml

from _utils import TEST_DIRS
from _utils import import_or_skip
from _utils import remove_module

# pylint: disable=redefined-outer-name
Expand All @@ -30,12 +29,12 @@
"for details on installing these additional dependencies")


@pytest.fixture(autouse=True, scope='session')
def dask_distributed(fail_missing: bool):
@pytest.fixture(name="dask_distributed", autouse=True, scope='session')
def dask_distributed_fixture(dask_distributed):
"""
All of the tests in this subdir requires dask.distributed
"""
yield import_or_skip("dask.distributed", reason=SKIP_REASON, fail_missing=fail_missing)
yield dask_distributed


@pytest.fixture(name="config")
Expand Down
9 changes: 3 additions & 6 deletions tests/morpheus/utils/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@

import morpheus.utils.downloader
from _utils import TEST_DIRS
from _utils import import_or_skip
from morpheus.utils.downloader import DOWNLOAD_METHODS_MAP
from morpheus.utils.downloader import Downloader
from morpheus.utils.downloader import DownloadMethods


@pytest.fixture(autouse=True, scope='session')
def dask_distributed(fail_missing: bool):
@pytest.fixture(name="dask_distributed", autouse=True, scope='session')
def dask_distributed_fixture(dask_distributed):
"""
Mark tests requiring dask.distributed
"""
yield import_or_skip("dask.distributed",
reason="Downloader requires dask and dask.distributed",
fail_missing=fail_missing)
yield dask_distributed


@pytest.mark.usefixtures("restore_environ")
Expand Down
20 changes: 10 additions & 10 deletions tests/morpheus_dfp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@
"Morpheus development environment.")


@pytest.fixture(autouse=True, scope='session')
def dask_distributed(fail_missing: bool):
@pytest.fixture(name="dask_distributed", autouse=True, scope='session')
def dask_distributed_fixture(dask_distributed):
"""
Mark tests requiring dask.distributed
"""
yield import_or_skip("dask.distributed", reason=SKIP_REASON, fail_missing=fail_missing)
yield dask_distributed


@pytest.fixture(autouse=True, scope='session')
def dask_cuda(fail_missing: bool):
@pytest.fixture(name="dask_cuda", autouse=True, scope='session')
def dask_cuda_fixture(dask_cuda):
"""
Mark tests requiring dask.distributed
Mark tests requiring dask_cuda
"""
yield import_or_skip("dask_cuda", reason=SKIP_REASON, fail_missing=fail_missing)
yield dask_cuda


@pytest.fixture(autouse=True, scope='session')
def mlflow(fail_missing: bool):
@pytest.fixture(name="mlflow", autouse=True, scope='session')
def mlflow_fixture(mlflow):
"""
Mark tests requiring mlflow
"""
yield import_or_skip("mlflow", reason=SKIP_REASON, fail_missing=fail_missing)
yield mlflow


@pytest.fixture(name='ae_feature_cols', scope='session')
Expand Down

0 comments on commit ea6b154

Please sign in to comment.