Skip to content

Commit

Permalink
Merge branch 'main' into feature/19_move_slc_notebook_to_repo_ai_lab
Browse files Browse the repository at this point in the history
  • Loading branch information
tomuben authored Jul 12, 2024
2 parents b01a015 + d358a2e commit 5765a67
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 130 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/check_documentation_links.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/check_version.yaml

This file was deleted.

53 changes: 36 additions & 17 deletions .github/workflows/check_ci.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
name: CI Build
name: CI

on:
push:
branches-ignore:
- "main"
pull_request:

jobs:
run_unit_tests:
run-unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run shellcheck
run: ./scripts/build/shellcheck.sh

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: "3.10"
poetry-version: '1.8.2'
poetry-version: "1.8.2"

- name: Check Version Number
run: poetry run python3 -u "./scripts/build/check_release.py"

- name: Run Unit Tests
run: >
Expand All @@ -28,14 +33,14 @@ jobs:
--override-ini=log_cli_level=INFO
test/unit
run_integration_tests:
run-integration-tests:
name: Integration Tests
environment: AWS_CI_TESTS
runs-on: ubuntu-latest
needs: run_unit_tests
needs: run-unit-tests

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -61,8 +66,7 @@ jobs:
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: "3.10"
poetry-version: '1.8.2'

poetry-version: "1.8.2"

- name: Run Integration Tests
run: >
Expand All @@ -76,15 +80,23 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}

run_notebook_tests:
approval-for-notebook-tests:
name: Run Jupyter Notebook Tests?
runs-on: ubuntu-latest
steps:
- name: Detect Running Notebook Tests
run: true
environment:
approve-test-execution

run-notebook-tests:
name: Jupyter Notebook Tests
if: "contains(github.event.head_commit.message, '[run-notebook-tests]')"
environment: AWS_SAGEMAKER
runs-on: ubuntu-latest
needs: run_unit_tests
needs: approval-for-notebook-tests

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -110,8 +122,7 @@ jobs:
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: "3.10"
poetry-version: '1.8.2'

poetry-version: "1.8.2"

- name: Run notebook tests
run: >
Expand All @@ -127,3 +138,11 @@ jobs:
SAAS_HOST: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_HOST }}
SAAS_ACCOUNT_ID: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_ACCOUNT_ID }}
SAAS_PAT: ${{ secrets.INTEGRATION_TEAM_SAAS_STAGING_PAT }}

gate-2:
name: Gate 2 - Allow Merge
runs-on: ubuntu-latest
needs: [ run-unit-tests, run-integration-tests, run-notebook-tests ]
steps:
- name: Branch Protection
run: true
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
name: Check Notebook Links
name: Check Hyperlinks

on:
push:
branches-ignore:
- "main"
pull_request:

jobs:
check_notebook_links:
check-links:
name: Find Broken Links in Documentation and Jupyter Notebooks
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: "3.10"
poetry-version: '1.8.2'

- name: Run build ai-lab tests
- name: Check Hyperlinks in Documentation
id: lychee
uses: lycheeverse/[email protected]
with:
fail: true
args: --verbose --no-progress 'doc/**/*.md' 'README.md'

- name: Check Hyperlinks in Jupyter Notebooks
run: >
poetry run pytest --check-links exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/
15 changes: 0 additions & 15 deletions .github/workflows/shellcheck.yaml

This file was deleted.

5 changes: 4 additions & 1 deletion doc/changes/changes_2.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Version: 2.1.0

## Bug Fixes

* #289 Fixed UI in notebooks
n/a

## Documentation

Expand All @@ -35,3 +35,6 @@ Version: 2.1.0
* #267: Switched CodeBuildWaiter to use tenacity
* #276: Started using the new ITDE Manager interface in the notebook-connector 0.2.9
* #282: Updated python version to Python 3.10
* #295: Made notebook-tests mandatory for merge
* #193: Ignored warnings in notebook tests
* #297: Reduced log level for transitive libraries in notebook tests
12 changes: 4 additions & 8 deletions doc/developer_guide/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
The project has two types of CI tests:
* Unit tests and integration tests which run in a Github workflow
* Special integration tests verifying the content of the Jupyter notebook files
* A system test which runs on a AWS Codebuild
* A system test which runs in a AWS Codebuild

All these tests need to pass before the approval of a Github PR.
The Github workflow will run on each push to a branch in the Github repository.

However, the notebook tests and the AWS Codebuild will only run after you push a commit containing a special string in the commit message, see the following sections.
However, the notebook tests and the AWS Codebuild will only run under specific conditions, e.g. manual approval or push a commit containing a special string in the commit message, see the following sections.

### Executing Notebook Tests
### Executing Jupyter Notebook Tests

Use the following git commands to execute the notebook tests:

```shell
git commit -m "[run-notebook-tests]" --allow-empty && git push
```
The regular CI build will ask for confirmation (aka. "review") before executing these tests, see [ETAJ developer guide](https://github.com/exasol/exasol-test-setup-abstraction-java/blob/main/doc/developer_guide/developer_guide.md#ci-build) for details.

### Executing AWS CodeBuild

Expand Down
1 change: 1 addition & 0 deletions test/integration/test_create_dss_docker_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def user_and_group(ls_line: str) -> str:
'bind': notebooks_folder,
'mode': 'rw', }, },
) as container:
wait_for(container, "entrypoint.py: Did chown -R")
testees = [tmp_path, child, sub, grand_child]
command = ls_command(str(tmp_path), notebooks_folder, testees)
output = assert_exec_run(container, command, user=JUPYTER_USER)
Expand Down
34 changes: 13 additions & 21 deletions test/notebook_test_runner/test_notebooks_in_dss_docker_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,46 +67,38 @@ def notebook_test_container(request, notebook_test_image):

@pytest.fixture()
def notebook_test_container_with_log(notebook_test_container):
wait_for_socket_access(notebook_test_container)
logs = notebook_test_container.logs().decode("utf-8").strip()
container = notebook_test_container
wait_for_socket_access(container)
logs = container.logs().decode("utf-8").strip()
print(f"Container Logs: {logs or '(empty)'}", flush=True)
yield notebook_test_container


def ignored_warnings():
warnings = {
"DeprecationWarning": [
"Jupyter is migrating its paths to use standard platformdirs",
"pkg_resources is deprecated as an API",
"Deprecated call to \\`pkg_resources.declare_namespace",
]
}
args = ""
for category, messages in warnings.items():
for m in messages:
args += f' -W "ignore:{m}:{category}"'
return args
yield container


@pytest.mark.parametrize(
"notebook_test_file",
[
python_file.name
for python_file in TEST_RESOURCE_PATH.glob("nbtest_*.py")
for python_file in sorted(TEST_RESOURCE_PATH.glob("nbtest_*.py"))
if python_file.is_file()
]
)
def test_notebook(notebook_test_container_with_log, notebook_test_file):
_logger.info(f"Running notebook tests for {notebook_test_file}")
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 {notebook_test_file}"
f"{ignored_warnings()}"
)
environ = os.environ.copy()
environ["NBTEST_ACTIVE"] = "TRUE"
nbtest_environ = {key: value for key, value in environ.items() if (
key.startswith("NBTEST_") or key.startswith("SAAS_"))}
exec_command(command_run_test, container, print_output=True, environment=nbtest_environ, user="jupyter")
exec_command(
command_run_test,
container,
print_output=True,
environment=nbtest_environ,
user="jupyter",
)
8 changes: 7 additions & 1 deletion test/notebooks/disabled_nbtest_cloud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import os
from notebook_test_utils import (access_to_temp_secret_store, notebook_runner)
from notebook_test_utils import (
access_to_temp_secret_store,
notebook_runner,
set_log_level_for_libraries,
)

set_log_level_for_libraries()


def test_cloud_notebook(notebook_runner) -> None:
Expand Down
2 changes: 2 additions & 0 deletions test/notebooks/nbtest_itde.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
take_itde_down
)
from exasol.nb_connector.connections import open_pyexasol_connection
from notebook_test_utils import set_log_level_for_libraries

set_log_level_for_libraries()

def test_itde(tmp_path):
store_path = tmp_path / 'tmp_config.sqlite'
Expand Down
18 changes: 12 additions & 6 deletions test/notebooks/nbtest_sagemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
from exasol.nb_connector.secret_store import Secrets
from exasol.nb_connector.ai_lab_config import AILabConfig as CKey, StorageBackend

from notebook_test_utils import (access_to_temp_secret_store,
access_to_temp_saas_secret_store,
run_notebook,
uploading_hack)
from notebook_test_utils import (
access_to_temp_secret_store,
access_to_temp_saas_secret_store,
run_notebook,
uploading_hack,
set_log_level_for_libraries,
)


set_log_level_for_libraries()


def _create_aws_s3_bucket() -> str:
Expand Down Expand Up @@ -170,7 +176,7 @@ def continuous_job_polling():
time.sleep(30)
query_result = conn.execute(sql)
job_status = query_result.fetchall()[0][0]
continuous_job_polling()
""")
)
Expand All @@ -186,7 +192,7 @@ def test_sagemaker(access_to_temp_secret_store, uploading_hack):
bucket_name = _create_aws_s3_bucket()
role_name = _create_sagemaker_role_with_policy()
_store_aws_credentials(store_path, store_password, bucket_name, role_name)

current_dir = os.getcwd()
try:
run_notebook('main_config.ipynb', store_file, store_password)
Expand Down
Loading

0 comments on commit 5765a67

Please sign in to comment.