Skip to content

Commit

Permalink
Merge branch 'Teradata:main' into light-and-dark-theme-update
Browse files Browse the repository at this point in the history
  • Loading branch information
patalvarado authored Feb 6, 2025
2 parents e5e9c29 + 22382c8 commit 878da66
Show file tree
Hide file tree
Showing 34 changed files with 1,068 additions and 121 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defaults:
shell: bash

jobs:
tests:
playwright-tests:
permissions:
contents: 'read'
id-token: 'write'
Expand All @@ -31,7 +31,7 @@ jobs:
CSAE_PARALLEL_TESTS_COUNT: ${{ vars.CSAE_PARALLEL_TESTS_COUNT }}
CSAE_WORKERS_COUNT: ${{ vars.CSAE_WORKERS_COUNT }}
TEST_ENV: ${{ github.event.inputs.test_env || 'PROD' }}
CSAE_CI_JOB_IDX: 0
CSAE_CI_JOB_IDX: 1
CSAE_CI_JOB_COUNT: 1
name: Playwirght Test
timeout-minutes: 1440
Expand Down
67 changes: 58 additions & 9 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ defaults:
shell: bash

jobs:
tests:
playwright-tests:
permissions:
contents: 'read'
id-token: 'write'
contents: 'read'
id-token: 'write'
strategy:
fail-fast: false
matrix: ${{ github.event.inputs.notebooks == '' && fromJson('{"idx":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}') || fromJson('{"idx":[0]}') }}
matrix: ${{ github.event.inputs.notebooks == '' && fromJson('{"idx":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}') || fromJson('{"idx":[1]}') }}
env:
CSAE_NOTEBOOKS: ${{ github.event.inputs.notebooks }}
CSAE_ENV_PASSWORD: ${{ secrets.CSAE_ENV_PASSWORD }}
Expand All @@ -43,6 +43,7 @@ jobs:
TEST_ENV: ${{ github.event.inputs.test_env || 'PROD' }}
CSAE_CI_JOB_COUNT: ${{ github.event.inputs.notebooks == '' && '10' || '1' }}
IGNORE_BLACKLIST: ${{ github.event.inputs.ignore_blacklist || 'false' }}
CI_ENV: 'nightly'
name: Job ${{ matrix.idx }}
timeout-minutes: 1440
runs-on: ubuntu-latest
Expand Down Expand Up @@ -96,13 +97,61 @@ jobs:
run: npx ts-node pre_create_env.ts
- name: Run Playwright tests
run: |
npx playwright test
npx playwright test --shard=${{matrix.idx}}/10
- name: Delete test environments
if: always()
run: npx ts-node post_delete_env.ts
- uses: actions/upload-artifact@v4
if: always()
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.idx }}
path: .tests/blob-report
retention-days: 1

merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
permissions:
pages: 'write'
contents: 'read'
id-token: 'write'
needs: [playwright-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
name: playwright-report-job-${{ matrix.idx }}
path: .tests/all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report-attempt-${{ github.run_attempt }}
path: .tests/playwright-report/
retention-days: 30
retention-days: 14

- name: Setup pages
uses: actions/configure-pages@v5
- name: Upload report to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: .tests/playwright-report/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Job summary
run: |
echo "# Deployment result" >> $GITHUB_STEP_SUMMARY
echo "View the [Playwright report](https://teradata.github.io/jupyter-demos/)" >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions .tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.DS_Store
node_modules/
playwright-report/
blob-report/
files.txt
.env
32 changes: 16 additions & 16 deletions .tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.44.1",
"@types/node": "^20.17.6",
"@playwright/test": "^1.50.1",
"@types/node": "^20.17.16",
"dotenv-cli": "^7.4.2"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions .tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineConfig({
/* Opt out of parallel tests on CI. Dave-changed from 1 to 3 */
workers: process.env.CSAE_WORKERS_COUNT ? parseInt(process.env.CSAE_WORKERS_COUNT):undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
reporter: process.env.CI_ENV === 'nightly'? 'blob' : 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
Expand All @@ -41,6 +41,7 @@ export default defineConfig({

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
screenshot: 'only-on-failure'
},

/* Configure projects for major browsers */
Expand Down Expand Up @@ -82,8 +83,7 @@ export default defineConfig({
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

//outputDir: 'test-results/',
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
Expand Down
4 changes: 2 additions & 2 deletions .tests/pre_create_env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ console.log('CSAE_PARALLEL_TESTS_COUNT:', CSAE_PARALLEL_TESTS_COUNT);
console.log(`Need ${Math.floor(CSAE_WORKERS_COUNT/CSAE_PARALLEL_TESTS_COUNT)} environments`);

for (let i = 0; i < Math.floor(CSAE_WORKERS_COUNT/CSAE_PARALLEL_TESTS_COUNT); i++) {
const env = new Environments(`jupyter-demos-${ENV_PREFIX}-${i}`, 'us-central', CSAE_ENV_PASSWORD)
const env = new Environments(`jupyter-demos-${ENV_PREFIX}-${i}`, 'us-west', CSAE_ENV_PASSWORD)
envs.push(env.create());
}

console.log(`Creating ${envs.length} environments`);
Promise.all(envs).then(() => {
console.log('Environments created');
})
})
3 changes: 2 additions & 1 deletion .tests/skip_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
../UseCases/Language_Models_InVantage/Initialization_and_Model_Load.ipynb
../UseCases/Signal_Processing_and_Classification/Signal_Processing_and_Classification_Python.ipynb
../UseCases/AnomalyDetection_OutstandingAmount_FS/AnomalyDetection_OutstandingAmount_FeatureStore.ipynb
../UseCases/Recommendations_product_search/Recommendations_product_search_OpenSource_Python.ipynb
../UseCases/Recommendations_product_search/Recommendations_product_search_OpenSource_Python.ipynb
../ModelOps/12_ModelOps_Model_Factory_REST_Python.ipynb
41 changes: 18 additions & 23 deletions .tests/tests/jupytertest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ const CSAE_WORKERS_COUNT = parseInt(process.env.CSAE_WORKERS_COUNT || '1');
const CSAE_PARALLEL_TESTS_COUNT = parseInt(process.env.CSAE_PARALLEL_TESTS_COUNT || '1');
const envPool = new EnvPool(Math.floor(CSAE_WORKERS_COUNT / CSAE_PARALLEL_TESTS_COUNT));

const CSAE_CI_JOB_IDX = parseInt(process.env.CSAE_CI_JOB_IDX || '0');
const CSAE_CI_JOB_COUNT = parseInt(process.env.CSAE_CI_JOB_COUNT || '1');
const CI_BRANCH = process.env.CI_BRANCH || 'main';
const IGNORE_BLACKLIST = process.env.IGNORE_BLACKLIST || 'false';

const sleep = (ms) => new Promise(r => setTimeout(r, ms));

test.describe.configure({ mode: 'parallel' });
// files.txt will contain the list of files to be tested.
// It is generated by the following command:
Expand Down Expand Up @@ -68,20 +64,13 @@ if(process.env.CSAE_NOTEBOOKS){
}
}

const testCount = Math.ceil(files.length / CSAE_CI_JOB_COUNT);

for (let i = 0; i < testCount; i++) {

const idx = i * CSAE_CI_JOB_COUNT + CSAE_CI_JOB_IDX;
if (idx >= files.length) {
break;
}
const name = files[idx];
for (let i = 0; i < files.length ; i++) {
const name = files[i];
if (name === '') {
continue;
}


test(`test ${i}: ${name}`, async ({ page }, testInfo) => {
test.setTimeout(10800000);

Expand Down Expand Up @@ -146,17 +135,23 @@ for (let i = 0; i < testCount; i++) {
for (let i = 1; i <= dm; i++) {
// To continute the notebook the kernel should be in Idle state. i.e previous cell execution should be completed.
await page.locator('span[class="f1235lqo"] >> text="' + strKernelType + '| Idle"').waitFor({ timeout: 600000 });


const errorLocator = page.locator(".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']");
try {
//Check for any errors so far
if(strKernelType === "Python 3 (ipykernel) "){
await expect(page.locator(".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']").filter({ hasText: 'Traceback (most recent call last):' })).toHaveCount(0);
}else if(strKernelType === 'Teradata SQL '){
await expect(page.locator(".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']").filter({ hasNotText: '[Teradata Database] [Warning' })).toHaveCount(0);
}else{
await expect(page.locator(".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']")).toHaveCount(0);
if(strKernelType === "Python 3 (ipykernel) "){
await expect(errorLocator.filter({ hasText: 'Traceback (most recent call last):' })).toHaveCount(0);
}else if(strKernelType === 'Teradata SQL '){
await expect(errorLocator.filter({ hasNotText: '[Teradata Database] [Warning'})).toHaveCount(0);
}else{
await expect(errorLocator).toHaveCount(0);
}
await expect(page.locator(`div.jp-NotebookPanel:not(.p-mod-hidden)> div > div.jp-Cell:nth-child(${i})`)).toHaveClass(/jp-mod-active/);
}catch(e){
console.log('Error found in cell ' + i + ' with following error:');
console.log(await errorLocator.textContent())
throw e;
}
await expect(page.locator(`div.jp-NotebookPanel:not(.p-mod-hidden)> div > div.jp-Cell:nth-child(${i})`)).toHaveClass(/jp-mod-active/);

//restart the kernel if the cell has 'zero zero' text
const restartKernal = await page.locator(`div.jp-NotebookPanel:not(.p-mod-hidden)> div > div.jp-Cell:nth-child(${i})`)
.filter({ hasText: 'The simplest way to restart the Kernel is by typing zero zero:' });
Expand Down Expand Up @@ -263,4 +258,4 @@ for (let i = 0; i < testCount; i++) {

}
});
}
}
5 changes: 1 addition & 4 deletions .tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
"esModuleInterop": true,
},
"include": [
"src/**/*.ts",
"test/**/*.ts",
"test-helpers/**/*.ts",
"tests/**/*.ts",
"./package.json",
"./package-lock.json",
"./templates/**/*.mustache"
],
"exclude": ["node_modules"]
}
8 changes: 8 additions & 0 deletions ExperienceBot/.ExperienceBot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inputs:
- type: env
value: 'JUPYTER_NOTEBOOK_CI_OPEN_AI_KEY'
cell: 10
- type: text
value: 'no'
prompt: "Do you want to generate embeddings? ('yes'/'no'):"

5 changes: 5 additions & 0 deletions ExperienceBot/.ExperienceBot_NoCode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inputs:
- type: env
value: 'JUPYTER_NOTEBOOK_CI_OPEN_AI_KEY'
cell: 8

Loading

0 comments on commit 878da66

Please sign in to comment.