Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
radekosmulski committed Jul 5, 2023
1 parent 2129d70 commit 41f2299
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/unit/torch/examples/test_01_getting_started.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright (c) 2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import pytest
from testbook import testbook

from tests.conftest import REPO_ROOT


@testbook(REPO_ROOT / "examples/pytorch/01-Getting-started.ipynb", execute=False)
@pytest.mark.notebook
def test_example_01_getting_started(tb):
tb.inject(
"""
from unittest.mock import patch
from merlin.datasets.synthetic import generate_data
mock_train, mock_valid = generate_data(
input="movielens-1m",
num_rows=1000,
set_sizes=(0.8, 0.2)
)
p1 = patch(
"merlin.datasets.entertainment.get_movielens",
return_value=[mock_train, mock_valid]
)
p1.start()
"""
)
tb.execute()
metrics = tb.ref("metrics")
assert set(metrics[0].keys()) == set(
[
"val_loss",
"val_binary_accuracy",
"val_binary_auroc",
"val_binary_precision",
"val_binary_recall"
]
)

0 comments on commit 41f2299

Please sign in to comment.