From 3ef3ffa50f78fa3401d9a0e5790432cf9da76b8f Mon Sep 17 00:00:00 2001 From: Artem Yevsiukov Date: Thu, 19 Sep 2024 13:41:31 +0300 Subject: [PATCH] Added `ml-metadata-store` rockfile --- ml-metadata-server/rockcraft.yaml | 58 +++++++++++++++++++++++++++ ml-metadata-server/tests/test_rock.py | 0 ml-metadata-server/tox.ini | 51 +++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 ml-metadata-server/rockcraft.yaml create mode 100644 ml-metadata-server/tests/test_rock.py create mode 100644 ml-metadata-server/tox.ini diff --git a/ml-metadata-server/rockcraft.yaml b/ml-metadata-server/rockcraft.yaml new file mode 100644 index 0000000..4e7ed90 --- /dev/null +++ b/ml-metadata-server/rockcraft.yaml @@ -0,0 +1,58 @@ +# Based on: https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/distributions/otelcol/Dockerfile +name: ml-metadata-server +summary: Part of the ML Metadata (MLMD) framework. +description: | + ML Metadata is a framework for managing and tracking metadata associated with ML workflows. + It is part of the TensorFlow Extended (TFX) ecosystem, but it can be used independently as well. +version: "1.14.0" +license: Apache-2.0 +base: ubuntu@22.04 +run-user: _daemon_ + +platforms: + amd64: + +parts: + server: + plugin: nil + source: https://github.com/google/ml-metadata.git + source-tag: v1.14.0 + build-packages: + - build-essential + - git + - clang + - cmake + - make + - ca-certificates + - musl-dev + - openssl + - curl + - unzip + - software-properties-common + - python3-distutils + - python-is-python3 + - python3-dev + build-environment: + - CGO_ENABLED: 0 + - GOOS: linux + - BAZEL_VERSION: 5.3.0 + override-build: | + # Set up Bazel 5.3.0 + mkdir /bazel && cd /bazel + curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh && \ + curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \ + chmod +x bazel-*.sh && ./bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh && \ + cd $CRAFT_PART_BUILD && rm -f /bazel/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh + + #Build + bazel build -c opt --action_env=PATH \ + --define=grpc_no_ares=true --verbose_failures \ + //ml_metadata/metadata_store:metadata_store_server --cxxopt="-std=c++17" + + 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 --root=${CRAFT_PROJECT_DIR}/../bundles/ubuntu-22.04/rootfs/ -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) \ + > ${CRAFT_PART_INSTALL}/usr/share/rocks/dpkg.query diff --git a/ml-metadata-server/tests/test_rock.py b/ml-metadata-server/tests/test_rock.py new file mode 100644 index 0000000..e69de29 diff --git a/ml-metadata-server/tox.ini b/ml-metadata-server/tox.ini new file mode 100644 index 0000000..5866c2b --- /dev/null +++ b/ml-metadata-server/tox.ini @@ -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."