Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kf1.7 upgrade #251

Merged
merged 24 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '1.17.7'
go-version: '1.20.5'

- name: Gather dependencies
run: |
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/common_frontend_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Common Frontend Tests
on:
pull_request:
types:
- 'opened'
- 'synchronize'
- 'reopened'

jobs:
frontend-format-lint-check:
name: Check code format and lint
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Check frontend code formatting
run: |
cd frontend/common/kubeflow-common-lib
npm i
npm run format:check
- name: Check frontend code linting
run: |
cd frontend/common/kubeflow-common-lib
npm i
npm run lint-check

frontend-unit-tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node version to 12
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Kubeflow common library dependecies
run: |
cd frontend/common/kubeflow-common-lib
npm i
npm run test:prod
36 changes: 0 additions & 36 deletions .github/workflows/frontend_tests.yml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/jwa_frontend_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: JWA Frontend Tests
on:
pull_request:
types:
- 'opened'
- 'synchronize'
- 'reopened'

jobs:
frontend-format-linting-check:
name: Check code format and lint
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Check frontend formatting
run: |
cd frontend/jupyter
npm i
npm run format:check

- name: Check frontend code linting
run: |
cd frontend/jupyter
npm i
npm run lint-check

frontend-unit-tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node version to 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Kubeflow common library dependecies
run: |
cd frontend/common/kubeflow-common-lib
npm i
npm run build
npm link ./dist/kubeflow
- name: Install JWA dependencies
run: |
cd frontend/jupyter
npm i
npm link kubeflow
- name: Run unit tests
run: |
cd frontend/jupyter
npm run test:prod

run-ui-tests:
name: UI tests with Cypress
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node version to 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Kubeflow common library dependecies
run: |
cd frontend/common/kubeflow-common-lib
npm i
npm run build
npm link ./dist/kubeflow
- name: Install JWA dependencies
run: |
cd frontend/jupyter
npm i
npm link kubeflow
- name: Serve UI & run Cypress tests in Chrome and Firefox
run: |
cd frontend/jupyter
npm run serve & npx wait-on http://localhost:4200
npm run ui-test-ci-all
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 0: UI Build Stage
FROM node:12-alpine as frontend
FROM node:16-alpine as frontend
WORKDIR /src
ENV NG_CLI_ANALYTICS "ci"
RUN apk add --no-cache --virtual .gyp python3 make g++
Expand All @@ -22,7 +22,7 @@ RUN npm run build -- --output-path=./dist/rok --configuration=rok-prod
RUN ./node_modules/.bin/ng build --configuration production --localize

# Stage 1: Build with the golang image
FROM golang:1.17-alpine AS backend
FROM golang:1.20-alpine AS backend
RUN apk add git
WORKDIR /go/src/github.com/StatCan/jupyter-apis
COPY go.mod .
Expand Down
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The front-end is configured to proxy requests to the local API server. It
requires an environment variable (`KF_USER_ID`) to specify the current user –
this is passed to the API server as an HTTP header.

The following can be pasted in a script and executed. This uses the latest node lts version(v16.16.0).
The following can be pasted in a script and executed. This uses the latest node lts/gallium version(v16.20.0) with npm v8(8.19.4).
**NOTE**: `user` is when using vagrant. Use the email adress if it is the dev cluser (please never connect to prod directly)

```
Expand All @@ -70,12 +70,18 @@ npm link ./dist/kubeflow

cd ../../jupyter
npm i
npm link kubeflow --legacy-peer-deps
npm link kubeflow
KF_USER_ID=user npm start
```

For the kubecost data to be retrievable, the following will need to be executed `kubectl port-forward -n kubecost-system deployment/kubecost-cost-analyzer 9090`

### Testing backend Rest API

To test the backend, install the [Thunder Client extension](https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client). After being installed, it should appear in the vs code sidebar (it might require a restart first).
First thing is to make sure that the backend is running. Then, open Thunder Client from the vs code sidebar. You should be able to see multiple requests that can be made against the backend under the "Collections" tab, in the "Golang kubeflow" dropdown. From there, just select a request and hit "Send".
Some requests require certain parameters to have values. Those can be filled up under the "Env" tab.

### Running intergration tests

We use [Cypress](https://www.cypress.io/) to make our end-to-end tests.
Expand Down Expand Up @@ -147,26 +153,34 @@ Any push to an open PR that has the auto-deploy label on it allows developers to

Routes are defined in this repository [here](./main.go).

[Upstream](https://github.com/kubeflow/kubeflow/tree/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes), the endpoints are structures via request type (e.g. `GET`, `PUT`, `DELETE`).
[Upstream](https://github.com/kubeflow/kubeflow/tree/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes), the endpoints are structures via request type (e.g. `GET`, `PUT`, `DELETE`).

_Note_

- _that not all endpoints are included in the golang implementation_
- _to find the upstream endpoint, load the [Upstream](https://github.com/kubeflow/kubeflow/tree/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes)
- _to find the upstream endpoint, load the [Upstream](https://github.com/kubeflow/kubeflow/tree/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes)
and use search with the endpoint text!_

| Request Type | Golang Endpoint | Upstream Python Endpoint | Purpose |
| ------------ | ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| GET | /api/config | [/api/config](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L9) | |
| GET | /api/gpus | [/api/gpus](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L52) | |
| GET | /api/storageclasses/default | [/api/storageclasses/default](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/common/backend/kubeflow/kubeflow/crud_backend/routes/get.py#L26) | |
| GET | /api/namespaces/{namespace}/cost/allocation | Not found | Get the kubecost Allocation API |
| GET | /api/namespaces | [/api/namespaces](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/common/backend/kubeflow/kubeflow/crud_backend/routes/get.py#L10) | Get the list of namespaces |
| GET | /api/namespaces/{namespace} | Not found | Get namespace metadata |
| GET | /api/namespaces/{namespace}/notebooks | [/api/namespaces/\<namespace\>/notebooks](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L44) | Get the list of notebooks |
| POST | /api/namespaces/{namespace}/notebooks | [/api/namespaces/\<namespace\>/notebooks](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/default/routes/post.py#L11) | Create a notebook |
| DELETE | /api/namespaces/{namespace}/notebooks/{notebook} | [/api/namespaces/\<namespace\>/notebooks/<notebook>](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/delete.py#L9) | Update a notebook |
| PATCH | /api/namespaces/{namespace}/notebooks/{notebook} | [/api/namespaces/\<namespace\>/notebooks/<notebook](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/patch.py#L19) | Delete a notebook |
| GET | /api/namespaces/{namespace}/pvcs | [/api/namespaces/\<namespace\>/pvc](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L15) | List `PVC`s |
| DELETE | /api/namespaces/{namespace}/pvcs/{pvc} | [/api/namespaces/\<namespace\>/pvcs/<pvc>](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/volumes/backend/apps/default/routes/delete.py#L11) | Delete a `PVC` |
| GET | /api/namespaces/{namespace}/poddefaults | [/api/namespaces/\<namespace\>/poddefaults](https://github.com/kubeflow/kubeflow/blob/v1.6.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L25) | Get `PodDefault`s for a given namespace |
| Request Type | Golang Endpoint | Upstream Python Endpoint | Purpose |
| --- | --- | --- | --- |
| GET | /api/config | [/api/config](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L13) | Gets the spawner_ui_config.yaml |
| GET | /api/gpus | [/api/gpus](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L101) | Reads the GPU vendors from the spawner config |
| GET | /api/storageclasses | [/api/storageclasses](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/common/backend/kubeflow/kubeflow/crud_backend/routes/get.py#L18) | list all storageclasses |
| GET | /api/storageclasses/default | [/api/storageclasses/default](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/common/backend/kubeflow/kubeflow/crud_backend/routes/get.py#L26) | gets the storage class with the `is-default-class` annotation |
| GET | /api/namespaces/{namespace}/cost/allocation | Not found | Get the kubecost Allocation API |
| GET | /api/namespaces | [/api/namespaces](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/common/backend/kubeflow/kubeflow/crud_backend/routes/get.py#L10) | Get the list of namespaces |
| GET | /api/namespaces/{namespace} | Not found | Get namespace metadata |
| GET | /api/namespaces/{namespace}/notebooks | [/api/namespaces/\<namespace\>/notebooks](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L52) | Get the list of notebooks |
| POST | /api/namespaces/{namespace}/notebooks | [/api/namespaces/\<namespace\>/notebooks](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/default/routes/post.py#L11) | Create a notebook |
| GET | /api/namespaces/{namespace}/notebooks/{notebook} | [/api/namespaces/\<namespace\>/notebooks/\<name\>](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L59) | Get a notebook |
| GET | /api/namespaces/{namespace}/notebooks/{notebook}/pod | [/api/namespaces/\<namespace\>/notebooks/\<notebook_name\>/pod](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L64) | Gets pod of notebook |
| GET | /api/namespaces/{namespace}/notebooks/{notebook}/pod/{pod_name}/logs | [/api/namespaces/\<namespace\>/notebooks/\<notebook_name\>/pod/\<pod_name\>/logs](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L81) | Gets logs of pod of notebook |
| GET | /api/namespaces/{namespace}/notebooks/{notebook}/events | [/api/namespaces/\<namespace\>/notebooks/\<notebook_name\>/events](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L90) | Gets events of notebook |
| DELETE | /api/namespaces/{namespace}/notebooks/{notebook} | [/api/namespaces/\<namespace\>/notebooks/\<notebook\>](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/delete.py#L9) | Delete a notebook |
| PATCH | /api/namespaces/{namespace}/notebooks/{notebook} | [/api/namespaces/\<namespace\>/notebooks/\<notebook\>](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/patch.py#L19) | Update a notebook |
| GET | /api/namespaces/{namespace}/pvcs | [/api/namespaces/\<namespace\>/pvcs](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/volumes/backend/apps/default/routes/get.py#L9) | List `PVC`s |
| GET | /api/namespaces/{namespace}/pvcs/{pvc} | [/api/namespaces/\<namespace\>/pvcs/\<pvc_name\>](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/volumes/backend/apps/default/routes/get.py#L19) | Gets a `PVC` |
| DELETE | /api/namespaces/{namespace}/pvcs/{pvc} | [/api/namespaces/\<namespace\>/pvcs/\<pvc\>](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/volumes/backend/apps/default/routes/delete.py#L11) | Delete a `PVC` |
| GET | /api/namespaces/{namespace}/pvcs/{pvc}/pods | [/api/namespaces/\<namespace\>/pvcs/\<pvc_name\>/pods](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/volumes/backend/apps/default/routes/get.py#L25) | Gets pods of a `PVC` |
| GET | /api/namespaces/{namespace}/pvcs/{pvc}/events | [/api/namespaces/\<namespace\>/pvcs/\<pvc_name\>/events](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/volumes/backend/apps/default/routes/get.py#L32) | Gets events of a `PVC` |
| GET | /api/namespaces/{namespace}/poddefaults | [/api/namespaces/\<namespace\>/poddefaults](https://github.com/kubeflow/kubeflow/blob/v1.7.0/components/crud-web-apps/jupyter/backend/apps/common/routes/get.py#L29) | Get `PodDefault`s for a given namespace |
51 changes: 51 additions & 0 deletions frontend/common/kubeflow-common-lib/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/member-ordering": "off",
"@angular-eslint/no-input-rename": "off",
"prefer-arrow/prefer-arrow-functions": "off",
"arrow-parens": [
"off",
"always"
],
"import/order": "off"
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
}
]
}
25 changes: 13 additions & 12 deletions frontend/common/kubeflow-common-lib/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"options": {
"tsConfig": "projects/kubeflow/tsconfig.lib.json",
"project": "projects/kubeflow/ng-package.json"
}
, "configurations": {
},
"configurations": {
"production": {
"tsConfig": "projects/kubeflow/tsconfig.lib.prod.json"
}
}
},
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
Expand All @@ -33,18 +33,19 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": [
"projects/kubeflow/tsconfig.lib.json",
"projects/kubeflow/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
"lintFilePatterns": [
"projects/kubeflow/**/*.ts",
"projects/kubeflow/**/*.html"
]
}
}
}
}},
"defaultProject": "kubeflow"
}
},
"defaultProject": "kubeflow",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}
Loading