forked from kubeflow/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a general notebook test script (kubeflow#763)
* add a general notebook test script * fix join * fix typo * infer notebook name with path * replace * fix name * add a log * update comment
- Loading branch information
1 parent
95db89a
commit c5222dd
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Runs notebook ipynb as test.""" | ||
|
||
import datetime | ||
import logging | ||
import os | ||
import re | ||
import uuid | ||
|
||
import pytest | ||
|
||
from kubeflow.examples.notebook_tests import nb_test_util | ||
from kubeflow.testing import util | ||
|
||
def test_run_notebook(record_xml_attribute, namespace, # pylint: disable=too-many-branches,too-many-statements | ||
repos, image, notebook_path): | ||
notebook_name = os.path.basename( | ||
notebook_path).replace(".ipynb", "").replace("_", "-") | ||
junit_name = "_".join(["test", notebook_name]) | ||
util.set_pytest_junit(record_xml_attribute, junit_name) | ||
|
||
name = "-".join([notebook_name, | ||
datetime.datetime.now().strftime("%H%M%S"), | ||
uuid.uuid4().hex[0:3]]) | ||
|
||
util.set_pytest_junit(record_xml_attribute, junit_name) | ||
nb_test_util.run_papermill_job(notebook_path, name, namespace, repos, image) | ||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.INFO, | ||
format=('%(levelname)s|%(asctime)s' | ||
'|%(pathname)s|%(lineno)d| %(message)s'), | ||
datefmt='%Y-%m-%dT%H:%M:%S', | ||
) | ||
logging.getLogger().setLevel(logging.INFO) | ||
pytest.main() |