Skip to content
New issue

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

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

Already on GitHub? # to your account

Update checks of HAS_GPU in tests to handle case where cudf is not installed #118

Merged
Merged
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
6 changes: 3 additions & 3 deletions tests/unit/dataloader/test_tf_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pytest
from sklearn.metrics import roc_auc_score

from merlin.core.compat import HAS_GPU, cupy
from merlin.core.compat import HAS_GPU, cudf, cupy
from merlin.core.dispatch import make_df, random_uniform
from merlin.io import Dataset
from merlin.schema import Tags
Expand Down Expand Up @@ -357,7 +357,7 @@ def add_sample_weight(features, labels, sample_weight_col_name="sample_weight"):
# TODO: include parts_per_chunk test
@pytest.mark.parametrize("gpu_memory_frac", [0.01, 0.06])
@pytest.mark.parametrize("batch_size", [1, 10, 100])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU else [True])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU and cudf else [True])
def test_tensorflow_dataloader(
tmpdir,
cpu,
Expand Down Expand Up @@ -633,7 +633,7 @@ def test_horovod_multigpu(tmpdir):


@pytest.mark.parametrize("batch_size", [1000])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU else [True])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU and cudf else [True])
def test_dataloader_schema(tmpdir, dataset, batch_size, cpu):
with tf_loader(
dataset,
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/dataloader/test_torch_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from conftest import assert_eq

from merlin.core import dispatch
from merlin.core.compat import HAS_GPU
from merlin.core.compat import HAS_GPU, cudf
from merlin.core.dispatch import make_df
from merlin.io import Dataset
from merlin.schema import Tags
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_torch_drp_reset(tmpdir, batch_size, drop_last, num_rows):
# Each column has only one unique value
# We test that each value in chunk (output of dataloader)
# is equal to every value in dataframe
if dispatch.HAS_GPU:
if cudf and isinstance(df, cudf.DataFrame):
assert (
np.expand_dims(chunk[0][col].cpu().numpy(), 1) == df[col].values_host
).all()
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_gpu_file_iterator_ds(df, dataset, batch):

@pytest.mark.parametrize("part_mem_fraction", [0.001, 0.06])
@pytest.mark.parametrize("batch_size", [1000])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU else [True])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU and cudf else [True])
def test_dataloader_break(dataset, batch_size, part_mem_fraction, cpu):
dataloader = torch_loader(
dataset,
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_dataloader_break(dataset, batch_size, part_mem_fraction, cpu):

@pytest.mark.parametrize("part_mem_fraction", [0.001, 0.06])
@pytest.mark.parametrize("batch_size", [1000])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU else [True])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU and cudf else [True])
def test_dataloader(df, dataset, batch_size, part_mem_fraction, cpu):
dataloader = torch_loader(
dataset,
Expand Down Expand Up @@ -336,7 +336,7 @@ def test_mh_support(multihot_dataset):


@pytest.mark.parametrize("batch_size", [1000])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU else [True])
@pytest.mark.parametrize("cpu", [False, True] if HAS_GPU and cudf else [True])
def test_dataloader_schema(df, dataset, batch_size, cpu):
with torch_loader(
dataset,
Expand Down