Skip to content
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
4 changes: 1 addition & 3 deletions .github/workflows/run-notebook-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ jobs:
python setup.py install
- name: Test with pytest
run: |
git diff --name-only ${{ github.base_ref }} examples/tutorials/translations/ examples/tutorials/translations/ > ./test/notebooks/git-diff.txt
pytest test/notebooks/test_notebooks.py::test_notebooks_basic_translations_diff
[ -e ./test/notebooks/git-diff.txt ] && rm ./test/notebooks/git-diff.txt
pytest test/notebooks/test_notebooks.py::test_notebooks_basic_translations
Empty file removed test/notebooks/git-diff.txt
Empty file.
40 changes: 0 additions & 40 deletions test/notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import urllib.request
from pathlib import Path
from zipfile import ZipFile
import codecs

import pytest
import nbformat
Expand Down Expand Up @@ -33,21 +32,6 @@
Path(nb).name for part in ["10", "13b", "13c"] for nb in translated_notebooks if part in nb
]


# Include only the translations that have been changed
gitdiff = Path("test/notebooks/git-diff.txt")
changed_files = []
if gitdiff.is_file():
changed_files = open(gitdiff, "r")
changed_files = changed_files.readlines()
changed_files = [
codecs.decode(file.replace('"', "").replace("\n", ""), "unicode-escape")
.encode("latin-1")
.decode()
for file in changed_files
]
translated_notebooks_diff = list(set(changed_files) & set(translated_notebooks))

# buggy notebooks with explanation what does not work
exclusion_list_notebooks = [
# Part 10 needs either torch.log2 to be implemented or numpy to be hooked
Expand Down Expand Up @@ -123,30 +107,6 @@ def test_notebooks_basic_translations(isolated_filesystem, translated_notebook):
assert isinstance(res, nbformat.notebooknode.NotebookNode)


@pytest.mark.parametrize(
"translated_notebook", sorted(set(translated_notebooks_diff) - set(excluded_notebooks))
)
def test_notebooks_basic_translations_diff(
isolated_filesystem, translated_notebook
): # pragma: no cover
"""
Test Notebooks in the tutorial translations folder if they have been
modified in the current pull request. This test should not consider any
notebooks locally. It should be used on Github Actions.
"""
notebook = "/".join(translated_notebook.split("/")[-2:])
notebook = f"translations/{notebook}"
list_name = Path(f"examples/tutorials/{notebook}")
tested_notebooks.append(str(list_name))
res = pm.execute_notebook(
notebook,
"/dev/null",
parameters={"epochs": 1, "n_test_batches": 5, "n_train_items": 64, "n_test_items": 64},
timeout=300,
)
assert isinstance(res, nbformat.notebooknode.NotebookNode)


@pytest.mark.parametrize("notebook", sorted(set(advanced_notebooks) - set(excluded_notebooks)))
def test_notebooks_advanced(isolated_filesystem, notebook):
notebook = notebook.replace("examples/tutorials/", "")
Expand Down