Skip to content

Commit

Permalink
fix: added test imports
Browse files Browse the repository at this point in the history
Summary of changes:
- Added test imports script and updated tox.ini to call it.
  • Loading branch information
Ivan Chvets committed Sep 28, 2023
1 parent fb17cf7 commit 27e2ae8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
24 changes: 24 additions & 0 deletions jupyter-tensorflow-full/tests/imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# This python script tests loading of required modules
#
import tensorflow as tf
import kfp
import kfp_server_api
import kfserving
import bokeh
import cloudpickle
import dill
import ipympl
import ipywidgets
import jupyterlab_git
import matplotlib
import pandas
# TO-DO verify how exactly scikit-image is installed
#import scikit_image
import scikit_learn
import scipy
import seaborn
import xgboost

# this string is expected by test script
print("PASSED")
29 changes: 29 additions & 0 deletions jupyter-tensorflow-full/tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
#
#
from pathlib import Path

import os
import subprocess
import yaml


def main():
"""Test running container and imports."""
rock = yaml.safe_load(Path("rockcraft.yaml").read_text())
name = rock["name"]
rock_version = rock["version"]
arch = list(rock["platforms"].keys())[0]
rock_image = f"{name}_{rock_version}_{arch}"
LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}"

print(f"Running command in {LOCAL_ROCK_IMAGE}")
script_command = ["bash", "-c", "export PYTHONPATH=$PYTHONPATH:/opt/conda/lib/python3.8/site-packages/keras/api/keras/wrappers/:/opt/conda/lib/python3.8/site-packages/ && python3 /home/jovyan/imports.py"]
pwd = os.getcwd()
output = subprocess.run(["docker", "run", "-v", f"{pwd}/tests/:/home/jovyan", LOCAL_ROCK_IMAGE, "exec", "pebble", "exec"] + script_command, stdout=subprocess.PIPE).stdout.decode('utf-8')
assert "PASSED" in output

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions jupyter-tensorflow-full/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ commands =
docker save $ROCK > $ROCK.tar'
# run rock tests
pytest -v --tb native --show-capture=all --log-cli-level=INFO {posargs} {toxinidir}/tests
python {toxinidir}/tests/test_imports.py
python {toxinidir}/tests/test_access.py

0 comments on commit 27e2ae8

Please sign in to comment.