Skip to content

Commit

Permalink
#324 Passing backend as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Aug 30, 2024
1 parent d23f4dc commit 8e05c67
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/notebook_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ jobs:
fail-fast: false
matrix:
nb_test:
- { name: "CSE notebook", test_file: "nbtest_cloud.py" }
- { name: "sklearn notebook", test_file: "nbtest_sklearn.py" }
- { name: "ibis notebook", test_file: "nbtest_ibis.py" }
- { name: "SLC notebook", test_file: "nbtest_script_languages_container.py" }
- { name: "SME notebooks", test_file: "nbtest_sagemaker.py"}
- { name: "TE notebooks", test_file: "nbtest_transformers.py"}
- { name: "short notebook tests", test_file: "\"nbtest_environment_test.py nbtest_itde.py\""}
- { name: "CSE notebook", test_file: "nbtest_cloud.py", test_backend: "all" }
- { name: "sklearn notebook", test_file: "nbtest_sklearn.py", test_backend: "all" }
- { name: "ibis notebook", test_file: "nbtest_ibis.py", test_backend: "all" }
- { name: "SLC notebook", test_file: "nbtest_script_languages_container.py", test_backend: "onprem" }
- { name: "SME notebooks onprem", test_file: "nbtest_sagemaker.py", test_backend: "onprem" }
- { name: "SME notebooks saas", test_file: "nbtest_sagemaker.py", test_backend: "saas" }
- { name: "TE notebooks onprem", test_file: "nbtest_transformers.py", test_backend: "onprem" }
- { name: "TE notebooks saas", test_file: "nbtest_transformers.py", test_backend: "saas"}
- { name: "short notebook tests", test_file: "\"nbtest_environment_test.py nbtest_itde.py\"", test_backend: "all"}
name: Running ${{ matrix.nb_test.name }}
steps:
- uses: actions/checkout@v4
Expand All @@ -33,6 +35,7 @@ jobs:
--override-ini=log_cli=true \
--override-ini=log_cli_level=INFO \
--nb-test-file=${{ matrix.nb_test.test_file }} \
--nb-test-backend=${{ matrix.nb_test.test_backend }} \
test/notebook_test_runner/test_notebooks_in_dss_docker_image.py
env:
SAAS_HOST: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_HOST }}
Expand Down
6 changes: 6 additions & 0 deletions test/notebook_test_runner/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

def pytest_addoption(parser):
parser.addoption("--nb-test-file", action="store", help="Notebook test file nbtest_*.py")
parser.addoption("--nb-test-backend", action="store", help="Backend to run the notebook test on")


@pytest.fixture
def notebook_test_file(request):
return request.config.getoption("--nb-test-file")


@pytest.fixture
def notebook_test_backend(request):
return request.config.getoption("--nb-test-backend")
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def notebook_test_container_with_log(notebook_test_container):
yield container


def test_notebook(notebook_test_container_with_log, notebook_test_file):
_logger.info(f"Running notebook tests for {notebook_test_file}")
def test_notebook(notebook_test_container_with_log, notebook_test_file, notebook_test_backend):
_logger.info(f"Running notebook tests for {notebook_test_file} at {notebook_test_backend}")
container = notebook_test_container_with_log
command_echo_virtual_env = 'bash -c "echo $VIRTUAL_ENV"'
virtual_env = exec_command(command_echo_virtual_env, container)
command_run_test = (
f"{virtual_env}/bin/python"
f" -m pytest --setup-show -s --backend=all {notebook_test_file}"
f" -m pytest --setup-show -s --backend={notebook_test_backend} {notebook_test_file}"
)
environ = os.environ.copy()
environ["NBTEST_ACTIVE"] = "TRUE"
Expand Down
8 changes: 5 additions & 3 deletions test/notebooks/nbtest_script_languages_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ def _store_slc_config(store_path: Path, store_password: str, clone_repo: bool):
conf.save(CKey.slc_source, slc_source)
conf.save(CKey.slc_target_dir, str(_slc_repo_dir()))


@pytest.fixture()
def cleanup_slc_repo_dir():
def cleanup_slc_repo_dir(backend):
import shutil
yield
p = Path.cwd() / "script_languages_container" / "script_languages_release"
shutil.rmtree(p)
if backend == BACKEND_ONPREM:
p = Path.cwd() / "script_languages_container" / "script_languages_release"
shutil.rmtree(p)


def test_script_languages_container_cloning_slc_repo(backend,
Expand Down

0 comments on commit 8e05c67

Please sign in to comment.