From c386c62ad51cb21c9e583a72ed2ab8b9114377d9 Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Mon, 20 May 2024 15:29:09 +0000 Subject: [PATCH 1/7] feat: add tensorboards-web-app rock v1.8 --- tensorboards-web-app/rockcraft.yaml | 135 ++++++++++++++++++++++++ tensorboards-web-app/tests/test_rock.py | 46 ++++++++ tensorboards-web-app/tox.ini | 54 ++++++++++ 3 files changed, 235 insertions(+) create mode 100644 tensorboards-web-app/rockcraft.yaml create mode 100644 tensorboards-web-app/tests/test_rock.py create mode 100644 tensorboards-web-app/tox.ini diff --git a/tensorboards-web-app/rockcraft.yaml b/tensorboards-web-app/rockcraft.yaml new file mode 100644 index 0000000..06a9211 --- /dev/null +++ b/tensorboards-web-app/rockcraft.yaml @@ -0,0 +1,135 @@ +name: tensorboards-web-app +summary: Tensorboards Web App +description: | + This web app is responsible for allowing the user to manipulate tensorboards in their Kubeflow + cluster. +version: "1.8" +license: Apache-2.0 +base: ubuntu@22.04 +platforms: + amd64: +run-user: _daemon_ + +services: + tensorboards-web-app: + override: replace + summary: "Tensorboards web app service" + startup: enabled + command: '/bin/bash -c "gunicorn -w 3 --bind 0.0.0.0:5000 --access-logfile - entrypoint:app"' + working-dir: "/src/" + +parts: + security-team-requirement: + plugin: nil + override-build: | + mkdir -p ${CRAFT_PART_INSTALL}/usr/share/rocks + (echo "# os-release" && cat /etc/os-release && echo "# dpkg-query" && \ + dpkg-query -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) \ + > ${CRAFT_PART_INSTALL}/usr/share/rocks/dpkg.query + + backend: + plugin: nil + source: https://github.com/kubeflow/kubeflow + source-type: git + source-tag: v1.8-branch + source-depth: 1 + build-packages: + - python3-venv + - python3-setuptools + - python3-pip + override-build: | + python3 -m pip install wheel + # Create a directory that holds the src of the backend copied + # from the CRAFT_PART_SRC directory to avoid bringing files that + # could affect the build of the backend wheel. + # This measure helps keeping the rockcraft and the Dockerfile files + # as similar as possible in terms of the operations they perform. + # This is replicated in other steps for the frontend. + mkdir $CRAFT_STAGE/backend-src && cd $CRAFT_STAGE/backend-src + cp -r $CRAFT_PART_SRC/components/crud-web-apps/common/backend/* $CRAFT_STAGE/backend-src/ + python3 setup.py bdist_wheel + + frontend-lib: + plugin: nil + source: https://github.com/kubeflow/kubeflow + source-type: git + source-tag: v1.8-branch + source-depth: 1 + build-snaps: + - node/12/stable + build-environment: + - NG_CLI_ANALYTICS: "ci" + override-build: | + mkdir $CRAFT_STAGE/frontend-lib-src/ && cd $CRAFT_STAGE/frontend-lib-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/common/frontend/kubeflow-common-lib/package.json $CRAFT_STAGE/frontend-lib-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/common/frontend/kubeflow-common-lib/package-lock.json $CRAFT_STAGE/frontend-lib-src/ + npm ci + + cp -r $CRAFT_PART_SRC/components/crud-web-apps/common/frontend/kubeflow-common-lib/projects/ $CRAFT_STAGE/frontend-lib-src/projects + cp $CRAFT_PART_SRC/components/crud-web-apps/common/frontend/kubeflow-common-lib/angular.json $CRAFT_STAGE/frontend-lib-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/common/frontend/kubeflow-common-lib/tsconfig.json $CRAFT_STAGE/frontend-lib-src/ + npm run build + + frontend: + after: [frontend-lib] + plugin: nil + source: https://github.com/kubeflow/kubeflow + source-type: git + source-tag: v1.8-branch + source-depth: 1 + build-snaps: + - node/12/stable + build-environment: + - NG_CLI_ANALYTICS: "ci" + override-build: | + mkdir $CRAFT_STAGE/frontend-src/ && cd $CRAFT_STAGE/frontend-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/package.json $CRAFT_STAGE/frontend-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/package-lock.json $CRAFT_STAGE/frontend-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/tsconfig.json $CRAFT_STAGE/frontend-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/tsconfig.app.json $CRAFT_STAGE/frontend-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/tsconfig.spec.json $CRAFT_STAGE/frontend-src/ + cp $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/angular.json $CRAFT_STAGE/frontend-src/ + mkdir $CRAFT_STAGE/frontend-src/src/ + cp -r $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/frontend/src/* $CRAFT_STAGE/frontend-src/src/ + npm ci + + mkdir -p $CRAFT_STAGE/frontend-src/node_modules/kubeflow + cp -r $CRAFT_STAGE/frontend-lib-src/dist/kubeflow/* $CRAFT_STAGE/frontend-src/node_modules/kubeflow + + npm run build -- --output-path=./dist --configuration=production + + webapp: + after: [backend, frontend] + plugin: nil + source: https://github.com/kubeflow/kubeflow + source-type: git + source-tag: v1.8-branch + source-depth: 1 + build-packages: + - python3-venv + - python3-setuptools + - python3-pip + override-build: | + cd $CRAFT_STAGE/backend-src/ && pip install . + + # Promote the packages we've installed from the local env to the primed image + mkdir -p $CRAFT_PART_INSTALL/usr/local/lib/python3.10/dist-packages + cp -fr /usr/local/lib/python3.10/dist-packages/* $CRAFT_PART_INSTALL/usr/local/lib/python3.10/dist-packages/ + + mkdir $CRAFT_PART_INSTALL/src && cd $CRAFT_PART_INSTALL/src + mkdir $CRAFT_PART_INSTALL/src/app/ + cp -r $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/backend/app/* $CRAFT_PART_INSTALL/src/app/ + cp -r $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/backend/entrypoint.py $CRAFT_PART_INSTALL/src/ + cp -r $CRAFT_PART_SRC/components/crud-web-apps/tensorboards/backend/Makefile $CRAFT_PART_INSTALL/src/ + + cp -r $CRAFT_STAGE/frontend-src/dist/ $CRAFT_PART_INSTALL/src/app/static + + gunicorn: + plugin: python + source: https://github.com/kubeflow/kubeflow.git + source-tag: v1.8-branch + source-depth: 1 + python-requirements: + - components/crud-web-apps/tensorboards/backend/requirements.txt + stage-packages: + - python3-venv diff --git a/tensorboards-web-app/tests/test_rock.py b/tensorboards-web-app/tests/test_rock.py new file mode 100644 index 0000000..49200a2 --- /dev/null +++ b/tensorboards-web-app/tests/test_rock.py @@ -0,0 +1,46 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. +# +# + +import pytest +import subprocess + +from charmed_kubeflow_chisme.rock import CheckRock + + +@pytest.mark.abort_on_fail +def test_rock(): + """Test rock.""" + check_rock = CheckRock("rockcraft.yaml") + rock_image = check_rock.get_name() + rock_version = check_rock.get_version() + LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}" + + # assert the rock contains the expected files + subprocess.run( + [ + "docker", + "run", + "--rm", + LOCAL_ROCK_IMAGE, + "exec", + "ls", + "-la", + "/src", + ], + check=True, + ) + + subprocess.run( + [ + "docker", + "run", + "--rm", + LOCAL_ROCK_IMAGE, + "exec", + "cat", + "/src/entrypoint.py", + ], + check=True, + ) \ No newline at end of file diff --git a/tensorboards-web-app/tox.ini b/tensorboards-web-app/tox.ini new file mode 100644 index 0000000..59fadfc --- /dev/null +++ b/tensorboards-web-app/tox.ini @@ -0,0 +1,54 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. +[tox] +skipsdist = True +skip_missing_interpreters = True +envlist = pack, export-to-docker, sanity, integration + +[testenv] +setenv = + PYTHONPATH={toxinidir} + PYTHONBREAKPOINT=ipdb.set_trace + CHARM_REPO=https://github.com/canonical/notebook-operators.git + CHARM_BRANCH=main + LOCAL_CHARM_DIR=charm_repo + +[testenv:pack] +passenv = * +allowlist_externals = + rockcraft +commands = + rockcraft pack + +[testenv:export-to-docker] +passenv = * +allowlist_externals = + bash + skopeo + yq +commands = + # export rock to docker + bash -c 'NAME=$(yq eval .name rockcraft.yaml) && \ + VERSION=$(yq eval .version rockcraft.yaml) && \ + ARCH=$(yq eval ".platforms | keys | .[0]" rockcraft.yaml) && \ + ROCK="$\{NAME\}_$\{VERSION\}_$\{ARCH\}.rock" && \ + DOCKER_IMAGE=$NAME:$VERSION && \ + echo "Exporting $ROCK to docker as $DOCKER_IMAGE" && \ + rockcraft.skopeo --insecure-policy copy oci-archive:$ROCK docker-daemon:$DOCKER_IMAGE' + +[testenv:sanity] +passenv = * +deps = + pytest + charmed-kubeflow-chisme +commands = + # run rock tests + pytest -s -v --tb native --show-capture=all --log-cli-level=INFO {posargs} {toxinidir}/tests + +[testenv:integration] +passenv = * +allowlist_externals = + echo +commands = + # TODO: Implement integration tests here + echo "WARNING: This is a placeholder test - no test is implemented here." From 1b83f57fc58ef3447e9a9e907ba9812030f7d239 Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Mon, 20 May 2024 15:30:22 +0000 Subject: [PATCH 2/7] skip: add Dockerfile link --- tensorboards-web-app/rockcraft.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorboards-web-app/rockcraft.yaml b/tensorboards-web-app/rockcraft.yaml index 06a9211..eef807a 100644 --- a/tensorboards-web-app/rockcraft.yaml +++ b/tensorboards-web-app/rockcraft.yaml @@ -1,3 +1,4 @@ +# Based on https://github.com/kubeflow/kubeflow/blob/v1.8-branch/components/crud-web-apps/tensorboards/Dockerfile name: tensorboards-web-app summary: Tensorboards Web App description: | From 0a2e0b837c1ad7114d8ad47c7d18646442af5bc3 Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Mon, 20 May 2024 15:36:06 +0000 Subject: [PATCH 3/7] skip: fix version --- tensorboards-web-app/rockcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorboards-web-app/rockcraft.yaml b/tensorboards-web-app/rockcraft.yaml index eef807a..e23634e 100644 --- a/tensorboards-web-app/rockcraft.yaml +++ b/tensorboards-web-app/rockcraft.yaml @@ -4,7 +4,7 @@ summary: Tensorboards Web App description: | This web app is responsible for allowing the user to manipulate tensorboards in their Kubeflow cluster. -version: "1.8" +version: "1.8.0" license: Apache-2.0 base: ubuntu@22.04 platforms: From 9ded64249c2188dddea8c328668090ad2fad2dfc Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Mon, 20 May 2024 15:38:02 +0000 Subject: [PATCH 4/7] skip: new line at EOF --- tensorboards-web-app/tests/test_rock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorboards-web-app/tests/test_rock.py b/tensorboards-web-app/tests/test_rock.py index 49200a2..3545057 100644 --- a/tensorboards-web-app/tests/test_rock.py +++ b/tensorboards-web-app/tests/test_rock.py @@ -43,4 +43,4 @@ def test_rock(): "/src/entrypoint.py", ], check=True, - ) \ No newline at end of file + ) From 1b873ce86f6bae1eb2895f10907658cf7d787260 Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Wed, 28 Aug 2024 09:21:07 +0000 Subject: [PATCH 5/7] update rock for 1.9 --- tensorboards-web-app/rockcraft.yaml | 14 +++++++------- tensorboards-web-app/tox.ini | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tensorboards-web-app/rockcraft.yaml b/tensorboards-web-app/rockcraft.yaml index e23634e..fcb4219 100644 --- a/tensorboards-web-app/rockcraft.yaml +++ b/tensorboards-web-app/rockcraft.yaml @@ -1,10 +1,10 @@ -# Based on https://github.com/kubeflow/kubeflow/blob/v1.8-branch/components/crud-web-apps/tensorboards/Dockerfile +# Based on https://github.com/kubeflow/kubeflow/blob/v1.9.0/components/crud-web-apps/tensorboards/Dockerfile name: tensorboards-web-app summary: Tensorboards Web App description: | This web app is responsible for allowing the user to manipulate tensorboards in their Kubeflow cluster. -version: "1.8.0" +version: "1.9" license: Apache-2.0 base: ubuntu@22.04 platforms: @@ -32,7 +32,7 @@ parts: plugin: nil source: https://github.com/kubeflow/kubeflow source-type: git - source-tag: v1.8-branch + source-tag: v1.9.0 source-depth: 1 build-packages: - python3-venv @@ -54,7 +54,7 @@ parts: plugin: nil source: https://github.com/kubeflow/kubeflow source-type: git - source-tag: v1.8-branch + source-tag: v1.9.0 source-depth: 1 build-snaps: - node/12/stable @@ -76,7 +76,7 @@ parts: plugin: nil source: https://github.com/kubeflow/kubeflow source-type: git - source-tag: v1.8-branch + source-tag: v1.9.0 source-depth: 1 build-snaps: - node/12/stable @@ -104,7 +104,7 @@ parts: plugin: nil source: https://github.com/kubeflow/kubeflow source-type: git - source-tag: v1.8-branch + source-tag: v1.9.0 source-depth: 1 build-packages: - python3-venv @@ -128,7 +128,7 @@ parts: gunicorn: plugin: python source: https://github.com/kubeflow/kubeflow.git - source-tag: v1.8-branch + source-tag: v1.9.0 source-depth: 1 python-requirements: - components/crud-web-apps/tensorboards/backend/requirements.txt diff --git a/tensorboards-web-app/tox.ini b/tensorboards-web-app/tox.ini index 59fadfc..bb38d9d 100644 --- a/tensorboards-web-app/tox.ini +++ b/tensorboards-web-app/tox.ini @@ -34,7 +34,7 @@ commands = ROCK="$\{NAME\}_$\{VERSION\}_$\{ARCH\}.rock" && \ DOCKER_IMAGE=$NAME:$VERSION && \ echo "Exporting $ROCK to docker as $DOCKER_IMAGE" && \ - rockcraft.skopeo --insecure-policy copy oci-archive:$ROCK docker-daemon:$DOCKER_IMAGE' + skopeo --insecure-policy copy oci-archive:$ROCK docker-daemon:$DOCKER_IMAGE' [testenv:sanity] passenv = * From 091330279a1a33f14e783a29d3cb14bd39f705e1 Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Fri, 30 Aug 2024 08:32:21 +0000 Subject: [PATCH 6/7] fix: rock version --- tensorboards-web-app/rockcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorboards-web-app/rockcraft.yaml b/tensorboards-web-app/rockcraft.yaml index fcb4219..fc964d4 100644 --- a/tensorboards-web-app/rockcraft.yaml +++ b/tensorboards-web-app/rockcraft.yaml @@ -4,7 +4,7 @@ summary: Tensorboards Web App description: | This web app is responsible for allowing the user to manipulate tensorboards in their Kubeflow cluster. -version: "1.9" +version: "1.9.0" license: Apache-2.0 base: ubuntu@22.04 platforms: From ccc0d1dabce93e130f6cdc97cb16ec8a8f3da32b Mon Sep 17 00:00:00 2001 From: NohaIhab Date: Mon, 2 Sep 2024 09:02:39 +0000 Subject: [PATCH 7/7] skip: address comment --- tensorboards-web-app/rockcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorboards-web-app/rockcraft.yaml b/tensorboards-web-app/rockcraft.yaml index fc964d4..fb70f46 100644 --- a/tensorboards-web-app/rockcraft.yaml +++ b/tensorboards-web-app/rockcraft.yaml @@ -97,7 +97,7 @@ parts: mkdir -p $CRAFT_STAGE/frontend-src/node_modules/kubeflow cp -r $CRAFT_STAGE/frontend-lib-src/dist/kubeflow/* $CRAFT_STAGE/frontend-src/node_modules/kubeflow - npm run build -- --output-path=./dist --configuration=production + npm run build -- --output-path=$CRAFT_STAGE/frontend-src/dist --configuration=production webapp: after: [backend, frontend]