Skip to content

Commit

Permalink
Updated katib-ui-rock (#45)
Browse files Browse the repository at this point in the history
* Updated `katib-ui-rock
  • Loading branch information
TakoB222 authored Sep 2, 2024
1 parent af31ca1 commit 158182c
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 7 deletions.
14 changes: 7 additions & 7 deletions katib-ui-rock/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Based on https://github.com/kubeflow/katib/blob/v0.16.0/cmd/ui/v1beta1/Dockerfile
# Based on https://github.com/kubeflow/katib/blob/v0.17.0/cmd/ui/v1beta1/Dockerfile
name: katib-ui
summary: Katib UI
description: |
Katib UI.
version: v0.16.0
version: v0.17.0
license: Apache-2.0
build-base: [email protected]
base: bare
base: [email protected]
run-user: _daemon_
services:
katib-ui:
Expand Down Expand Up @@ -51,7 +50,7 @@ parts:
plugin: nil
source: https://github.com/kubeflow/katib
source-type: git
source-tag: v0.16.0
source-tag: v0.17.0
source-depth: 1
build-snaps:
- node/12/stable
Expand All @@ -74,10 +73,10 @@ parts:
plugin: go
source: https://github.com/kubeflow/katib
source-type: git
source-tag: v0.16.0
source-tag: v0.17.0
build-snaps:
# Use go version that satisfies requirements in
# https://github.com/kubeflow/katib/blob/v0.16.0/docs/developer-guide.md#requirements
# https://github.com/kubeflow/katib/blob/v0.17.0/docs/developer-guide.md#requirements
- go/1.21/stable
build-environment:
- CGO_ENABLED: 0
Expand Down Expand Up @@ -108,3 +107,4 @@ parts:
mkdir -p ${CRAFT_PART_INSTALL}/usr/share/rocks
(echo "# os-release" && cat /etc/os-release && echo "# dpkg-query") \
> ${CRAFT_PART_INSTALL}/usr/share/rocks/dpkg.query
67 changes: 67 additions & 0 deletions katib-ui-rock/tests/test_rock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
#
#

from pathlib import Path

import os
import logging
import random
import pytest
import string
import subprocess
import yaml

from charmed_kubeflow_chisme.rock import CheckRock


@pytest.fixture()
def rock_test_env(tmpdir):
"""Yields a temporary directory and random docker container name, then cleans them up after."""
container_name = "".join(
[str(i) for i in random.choices(string.ascii_lowercase, k=8)]
)
yield tmpdir, container_name

try:
subprocess.run(["docker", "rm", container_name])
except Exception:
pass
# tmpdir fixture we use here should clean up the other files for us


@pytest.mark.abort_on_fail
def test_rock(rock_test_env):
"""Test rock."""
temp_dir, container_name = rock_test_env
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}"

subprocess.run(
[
"docker",
"run",
LOCAL_ROCK_IMAGE,
"exec",
"ls",
"-la",
"/app/katib-ui",
],
check=True,
)

subprocess.run(
[
"docker",
"run",
LOCAL_ROCK_IMAGE,
"exec",
"ls",
"-la",
"/app/build/static",
],
check=True,
)
51 changes: 51 additions & 0 deletions katib-ui-rock/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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

[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" && \
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."

0 comments on commit 158182c

Please sign in to comment.