Skip to content

Commit

Permalink
Update Dask Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Jan 21, 2025
1 parent ed5be99 commit a0e0f56
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
23 changes: 14 additions & 9 deletions holoviews/tests/core/data/test_daskinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
from holoviews.core.util import PANDAS_VERSION
from holoviews.util.transform import dim

from ...utils import dask_switcher
from ...utils import DASK_VERSION, dask_setup, dask_switcher
from .test_pandasinterface import BasePandasInterfaceTests

try:
import dask_expr
except ImportError:
dask_expr = None
classic, expr = dask_setup()


class _DaskDatasetTest(BasePandasInterfaceTests):
Expand Down Expand Up @@ -136,9 +133,11 @@ def test_select_expression_lazy(self):

class DaskClassicDatasetTest(_DaskDatasetTest):

data_type = dd.core.DataFrame
# No longer supported from Dask 2025.1

__test__ = True
data_type = getattr(dd.core, "DataFrame", None)

__test__ = classic

@dask_switcher(query=False)
def setUp(self):
Expand All @@ -147,11 +146,17 @@ def setUp(self):

class DaskExprDatasetTest(_DaskDatasetTest):

__test__ = bool(dask_expr)
__test__ = expr

@property
def data_type(self):
return dask_expr.DataFrame
# Only available from 2025.1 and forward
if DASK_VERSION >= (2025, 1, 0):
return dd.DataFrame
else:
import dask_expr

return dask_expr.DataFrame

@dask_switcher(query=True)
def setUp(self):
Expand Down
10 changes: 5 additions & 5 deletions holoviews/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import param
import pytest
from packaging.version import Version

from holoviews.core.util import _no_import_version
from holoviews.element.comparison import ComparisonTestCase

cwd = os.path.abspath(os.path.split(__file__)[0])
Expand Down Expand Up @@ -120,21 +120,21 @@ def tearDown(self):


DASK_UNAVAILABLE = find_spec("dask") is None
DASK_VERSION = _no_import_version("dask")


@lru_cache
def _dask_setup():
def dask_setup():
"""
Set-up both dask dataframes, using lru_cahce to only do it once
"""
import dask
from datashader.data_libraries.dask import bypixel, dask_pipeline

classic, expr = False, False

# Removed in Dask 2025.1, and will raise AttributeError
if Version(dask.__version__).release < (2025, 1, 0):
if DASK_VERSION < (2025, 1, 0):
import dask.dataframe as dd

bypixel.pipeline.register(dd.core.DataFrame)(dask_pipeline)
Expand Down Expand Up @@ -164,7 +164,7 @@ def dask_switcher(*, query=False, extras=None):
if DASK_UNAVAILABLE:
pytest.skip("dask is not available")

classic, expr = _dask_setup()
classic, expr = dask_setup()

if not query and not classic:
pytest.skip("Classic DataFrame no longer supported by dask")
Expand Down

0 comments on commit a0e0f56

Please sign in to comment.