From 2e67d1c72a016298d31de1c0a3abe3f194cf3800 Mon Sep 17 00:00:00 2001 From: Florian Jacobs Date: Fri, 2 Aug 2024 17:13:25 +0200 Subject: [PATCH 01/32] add python 3.12 to compatibility and testing --- .gitlab-ci.yml | 28 ++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 342d72ab..3c571099 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -161,6 +161,34 @@ test_python_311: rules: - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH +test_python_312: + stage: test + image: python:3.12 + script: + - set -e + - "echo 'import coverage; coverage.process_startup()' > sitecustomize.py" + - export PYTHONPATH=$PWD + - export COVERAGE_PROCESS_START=$PWD/.coveragerc + - poetry run coverage run --source hannah -m pytest test + - unset PYTHONPATH + - unset COVERAGE_PROCESS_START + - poetry run coverage report + - poetry run coverage xml + tags: + - gpu + interruptible: true + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + dependencies: [] + cache: + paths: + - .cache/ + rules: + - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + build_docs: stage: test diff --git a/pyproject.toml b/pyproject.toml index f08fb94b..aaee7c21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ packages = [ [tool.poetry.dependencies] -python = ">=3.9 <3.12" +python = ">=3.9 <3.13" pwlf = "^2.0.0" gitdb2 = "2.0.6" chainmap = "^1.0.3" From 158853a2ca23f7cd4149090e1950974fb84b4961 Mon Sep 17 00:00:00 2001 From: Florian Jacobs Date: Fri, 9 Aug 2024 14:08:55 +0200 Subject: [PATCH 02/32] poetry lock --- poetry.lock | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index cd2a63fd..5216c55e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3115,7 +3115,8 @@ files = [ numpy = [ {version = ">=1.21.0", markers = "python_version == \"3.9\" and platform_system == \"Darwin\" and platform_machine == \"arm64\""}, {version = ">=1.19.3", markers = "platform_system == \"Linux\" and platform_machine == \"aarch64\" and python_version >= \"3.8\" and python_version < \"3.10\" or python_version > \"3.9\" and python_version < \"3.10\" or python_version >= \"3.9\" and platform_system != \"Darwin\" and python_version < \"3.10\" or python_version >= \"3.9\" and platform_machine != \"arm64\" and python_version < \"3.10\""}, - {version = ">=1.23.5", markers = "python_version >= \"3.11\""}, + {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, + {version = ">=1.23.5", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, {version = ">=1.21.4", markers = "python_version >= \"3.10\" and platform_system == \"Darwin\" and python_version < \"3.11\""}, {version = ">=1.21.2", markers = "platform_system != \"Darwin\" and python_version >= \"3.10\" and python_version < \"3.11\""}, ] @@ -3140,7 +3141,8 @@ files = [ numpy = [ {version = ">=1.21.0", markers = "python_version == \"3.9\" and platform_system == \"Darwin\" and platform_machine == \"arm64\""}, {version = ">=1.19.3", markers = "platform_system == \"Linux\" and platform_machine == \"aarch64\" and python_version >= \"3.8\" and python_version < \"3.10\" or python_version > \"3.9\" and python_version < \"3.10\" or python_version >= \"3.9\" and platform_system != \"Darwin\" and python_version < \"3.10\" or python_version >= \"3.9\" and platform_machine != \"arm64\" and python_version < \"3.10\""}, - {version = ">=1.23.5", markers = "python_version >= \"3.11\""}, + {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, + {version = ">=1.23.5", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, {version = ">=1.21.4", markers = "python_version >= \"3.10\" and platform_system == \"Darwin\" and python_version < \"3.11\""}, {version = ">=1.21.2", markers = "platform_system != \"Darwin\" and python_version >= \"3.10\" and python_version < \"3.11\""}, ] @@ -5577,5 +5579,5 @@ vision = ["albumentations", "gdown", "imagecorruptions", "kornia", "pycocotools" [metadata] lock-version = "2.0" -python-versions = ">=3.9 <3.12" -content-hash = "67466fd5872956234decb86a98616b9fe3704c95729d19a0e302f0d6ad08d473" +python-versions = ">=3.9 <3.13" +content-hash = "1d0d3e0597cba73e2f7bd56ad774a1625a2c87506a64ae9864b0c2b410568db8" From 990d6e464ee9f1c27e2928c2da27013c2dbf828f Mon Sep 17 00:00:00 2001 From: Florian Jacobs Date: Fri, 9 Aug 2024 14:31:16 +0200 Subject: [PATCH 03/32] added poetry precommit hook to prevent stuck lockfiles --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91416c1b..835d204d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,3 +42,9 @@ repos: args: [--fix, --exit-non-zero-on-fix] # Formatter - id: ruff-format + - repo: https://github.com/python-poetry/poetry + rev: '1.8' + hooks: + - id: poetry-check + # - id: poetry-lock + # args: ['--no-update'] From c8e728a36843d3d7405f0f7b812e1f4818c46bb1 Mon Sep 17 00:00:00 2001 From: Florian Jacobs Date: Fri, 16 Aug 2024 12:18:27 +0200 Subject: [PATCH 04/32] added buildscript for testcontainers and manual; dind not working yet --- .gitlab-ci.yml | 76 ++++++++++----------------- Dockerfile.python3 | 44 ++++++++++++++++ build_testcontainer.sh | 114 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 184 insertions(+), 50 deletions(-) create mode 100644 Dockerfile.python3 create mode 100644 build_testcontainer.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c571099..387b1d18 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,22 +33,6 @@ variables: cache: key: "$CI_JOB_NAME" -before_script: - - apt update - - apt -y install git mesa-utils python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3 - - - # Install poetry using recommended method - - curl -sSL https://install.python-poetry.org/ | python3 - - export PATH=${POETRY_HOME}/bin:${PATH} - - # install and manage dependencies with poetry - - poetry config installer.max-workers 10 - - poetry install --all-extras - - # Show limits - - ulimit -a - test_prebuilt_docker: stage: test image: cgerum/hannah:latest @@ -69,21 +53,36 @@ test_prebuilt_docker: dependencies: [] +build_testcontainers: + stage: build + image: gitlab/gitlab-runner:latest + tags: + - dind + before_script: + - apk add --no-cache bash + script: + - bash ./build_testcontainer.sh all + allow_failure: false + when: manual + test_python_39: stage: test - image: python:3.9 + image: es-git-registry.cs.uni-tuebingen.de/es/ai/hannah/hannah/testing/python:3.9 script: - set -e + - poetry config installer.max-workers 10 + - poetry install -E vision - poetry run python3 -m pytest -v --cov=hannah test hannah --integration tags: - docker interruptible: true - rules: - - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH dependencies: [] cache: paths: - .cache/ + rules: + - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - when: manual #test_tvm: # stage: test @@ -107,9 +106,11 @@ test_python_39: test_python_310: stage: test - image: python:3.10 + image: es-git-registry.cs.uni-tuebingen.de/es/ai/hannah/hannah/testing/python:3.10 script: - set -e + - poetry config installer.max-workers 10 + - poetry install -E vision - "echo 'import coverage; coverage.process_startup()' > sitecustomize.py" - export PYTHONPATH=$PWD - export COVERAGE_PROCESS_START=$PWD/.coveragerc @@ -132,12 +133,15 @@ test_python_310: - .cache/ rules: - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + - when: manual test_python_311: stage: test - image: python:3.11 + image: es-git-registry.cs.uni-tuebingen.de/es/ai/hannah/hannah/es/ai/hannah/hannah/testing/python:3.11 script: - set -e + - poetry config installer.max-workers 10 + - poetry install -E vision - "echo 'import coverage; coverage.process_startup()' > sitecustomize.py" - export PYTHONPATH=$PWD - export COVERAGE_PROCESS_START=$PWD/.coveragerc @@ -160,35 +164,7 @@ test_python_311: - .cache/ rules: - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - -test_python_312: - stage: test - image: python:3.12 - script: - - set -e - - "echo 'import coverage; coverage.process_startup()' > sitecustomize.py" - - export PYTHONPATH=$PWD - - export COVERAGE_PROCESS_START=$PWD/.coveragerc - - poetry run coverage run --source hannah -m pytest test - - unset PYTHONPATH - - unset COVERAGE_PROCESS_START - - poetry run coverage report - - poetry run coverage xml - tags: - - gpu - interruptible: true - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - dependencies: [] - cache: - paths: - - .cache/ - rules: - - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - + - when: manual build_docs: stage: test diff --git a/Dockerfile.python3 b/Dockerfile.python3 new file mode 100644 index 00000000..4e08fb96 --- /dev/null +++ b/Dockerfile.python3 @@ -0,0 +1,44 @@ +# ARG for Python version, defaulting to 3.12 +ARG PYTHON_VERSION=3.12 + +# Use specified Python version as the base image +FROM python:${PYTHON_VERSION} + +# Set working directory +WORKDIR /data + +# Set environment variables +ENV PIP_CACHE_DIR="/data/.cache/pip" \ + POETRY_HOME="/data/.poetry" \ + POETRY_CACHE_DIR="/data/.cache/pypoetry" \ + GIT_SUBMODULE_STRATEGY="recursive" \ + DEBIAN_FRONTEND="noninteractive" + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + mesa-utils \ + python3-dev \ + libblas-dev \ + liblapack-dev \ + libsndfile1-dev \ + libsox-dev \ + cmake \ + ninja-build \ + && rm -rf /var/lib/apt/lists/* + +# Install Poetry +RUN curl -sSL https://install.python-poetry.org/ | python3 - +ENV PATH="${POETRY_HOME}/bin:${PATH}" + +# Copy project files +# COPY hannah/pyproject.toml hannah/poetry.lock* ./ + +COPY hannah/ ./ + +# Configure Poetry and install dependencies +RUN poetry config installer.max-workers 10 && \ + poetry install --with dev + +# Show limits (this will be executed when the container runs) +CMD ["sh", "-c", "ulimit -a && /bin/bash"] diff --git a/build_testcontainer.sh b/build_testcontainer.sh new file mode 100644 index 00000000..d65dc5e3 --- /dev/null +++ b/build_testcontainer.sh @@ -0,0 +1,114 @@ +#!/bin/bash +## +## Copyright (c) 2024 Hannah contributors. +## +## This file is part of hannah. +## See https://github.com/ekut-es/hannah for further info. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + + +# Define the Python versions to build +VERSIONS=(3.9 3.10 3.11 3.12) +# VERSIONS=(3.12) + +HANNAH_FOLDER=$(pwd)/hannah + +# Set the registry and namespace +REGISTRY="es-git-registry.cs.uni-tuebingen.de" +NAMESPACE="es/ai/hannah" +PROJECT="hannah" +IMAGE_NAME="testing/python" + + +get_tag() { + local VERSION="$1" + echo "${REGISTRY}/${NAMESPACE}/${PROJECT}/${IMAGE_NAME}:${VERSION}" +} + +build_image() { + local VERSION="$1" + local TAG=$(get_tag "$VERSION") + docker build -f Dockerfile.python3 --build-arg PYTHON_VERSION="${VERSION}" -t "${TAG}" . +} +# Function to push an image +push_image() { + local VERSION="$1" + local TAG=$(get_tag "$VERSION") + echo "Pushing image ${TAG}..." + docker push "${TAG}" +} + +# Function to test an image +test_image() { + local VERSION="$1" + local VERSION_WITHOUT_DOT=${VERSION/.} + cd $HANNAH_FOLDER + # --docker-pull-policy "never" + gitlab-runner exec docker --cicd-config-file ".gitlab-ci.yml" --clone-url "." "test_python_${VERSION_WITHOUT_DOT}" +} + +# Function to echo an image tag +echo_image() { + local VERSION="$1" + local TAG=$(get_tag "$VERSION") + echo "${TAG}" +} + +# Check if a second argument is provided to override VERSIONS +if [ -n "$2" ]; then + VERSIONS=("$2") +fi + + +# Default action is build +action=${1:-build} + +case "$action" in + push) + for VERSION in "${VERSIONS[@]}"; do + push_image "$VERSION" + done + ;; + + build) + for VERSION in "${VERSIONS[@]}"; do + build_image "$VERSION" + done + ;; + + test) + for VERSION in "${VERSIONS[@]}"; do + test_image "$VERSION" + done + ;; + + echo) + for VERSION in "${VERSIONS[@]}"; do + echo_image "$VERSION" + done + ;; + + all) + for VERSION in "${VERSIONS[@]}"; do + build_image "$VERSION" + test_image "$VERSION" + push_image "$VERSION" + done + ;; + + *) + echo "Unknown action: $action. Options are push build test" + ;; +esac From 8ecf2398073946adf5314208610befa63746a294 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:11:55 +0200 Subject: [PATCH 05/32] Use matrix build --- Dockerfile | 9 ++++ build_testcontainer.sh | 114 ----------------------------------------- 2 files changed, 9 insertions(+), 114 deletions(-) delete mode 100644 build_testcontainer.sh diff --git a/Dockerfile b/Dockerfile index d185a9cf..7b9434b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,12 +17,21 @@ ## limitations under the License. ## +# Target for python/mlonmcu/python ARG target="hannah" +# ARG for Python version, defaulting to 3.12 only used if python target is selected +ARG PYTHON_VERSION=3.12 + FROM ubuntu:22.04 as hannah FROM tumeda/mlonmcu-bench:latest as mlonmcu + +# Use specified Python version as the base image +FROM python:${PYTHON_VERSION} as python + + FROM ${target} diff --git a/build_testcontainer.sh b/build_testcontainer.sh deleted file mode 100644 index d65dc5e3..00000000 --- a/build_testcontainer.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -## -## Copyright (c) 2024 Hannah contributors. -## -## This file is part of hannah. -## See https://github.com/ekut-es/hannah for further info. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## - - -# Define the Python versions to build -VERSIONS=(3.9 3.10 3.11 3.12) -# VERSIONS=(3.12) - -HANNAH_FOLDER=$(pwd)/hannah - -# Set the registry and namespace -REGISTRY="es-git-registry.cs.uni-tuebingen.de" -NAMESPACE="es/ai/hannah" -PROJECT="hannah" -IMAGE_NAME="testing/python" - - -get_tag() { - local VERSION="$1" - echo "${REGISTRY}/${NAMESPACE}/${PROJECT}/${IMAGE_NAME}:${VERSION}" -} - -build_image() { - local VERSION="$1" - local TAG=$(get_tag "$VERSION") - docker build -f Dockerfile.python3 --build-arg PYTHON_VERSION="${VERSION}" -t "${TAG}" . -} -# Function to push an image -push_image() { - local VERSION="$1" - local TAG=$(get_tag "$VERSION") - echo "Pushing image ${TAG}..." - docker push "${TAG}" -} - -# Function to test an image -test_image() { - local VERSION="$1" - local VERSION_WITHOUT_DOT=${VERSION/.} - cd $HANNAH_FOLDER - # --docker-pull-policy "never" - gitlab-runner exec docker --cicd-config-file ".gitlab-ci.yml" --clone-url "." "test_python_${VERSION_WITHOUT_DOT}" -} - -# Function to echo an image tag -echo_image() { - local VERSION="$1" - local TAG=$(get_tag "$VERSION") - echo "${TAG}" -} - -# Check if a second argument is provided to override VERSIONS -if [ -n "$2" ]; then - VERSIONS=("$2") -fi - - -# Default action is build -action=${1:-build} - -case "$action" in - push) - for VERSION in "${VERSIONS[@]}"; do - push_image "$VERSION" - done - ;; - - build) - for VERSION in "${VERSIONS[@]}"; do - build_image "$VERSION" - done - ;; - - test) - for VERSION in "${VERSIONS[@]}"; do - test_image "$VERSION" - done - ;; - - echo) - for VERSION in "${VERSIONS[@]}"; do - echo_image "$VERSION" - done - ;; - - all) - for VERSION in "${VERSIONS[@]}"; do - build_image "$VERSION" - test_image "$VERSION" - push_image "$VERSION" - done - ;; - - *) - echo "Unknown action: $action. Options are push build test" - ;; -esac From 46aad636712e09b05f93da7ec542f7f957ac29e2 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:24:47 +0200 Subject: [PATCH 06/32] Build python versions --- .github/workflows/publish_images.yml | 16 ++++++++++++++-- .gitlab-ci.yml | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index f1281e7d..71f3ca18 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -30,18 +30,30 @@ on: # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. jobs: build-and-push-image: runs-on: ubuntu-latest + matrix: + image_name: + - python + - python_version: + - 3.9 + - 3.10 + - 3.11 + - 3.12 + + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. permissions: contents: read packages: write attestations: write # + + + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -57,7 +69,7 @@ jobs: id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ matrix.image_name }}_${{matrix.python_version }} # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 387b1d18..6f10f1a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -168,7 +168,7 @@ test_python_311: build_docs: stage: test - image: ubuntu:22.04 + image: ubuntu:20.04 variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" cache: From 5652d737a01c7d256438ca3db0c8207b5b70f7ba Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:32:59 +0200 Subject: [PATCH 07/32] Fix build matrix definition --- .github/workflows/publish_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 71f3ca18..352022bf 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -38,7 +38,7 @@ jobs: matrix: image_name: - python - - python_version: + python_version: - 3.9 - 3.10 - 3.11 From 1951c9b05a65c57476297480ab0cd72be062470b Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:35:57 +0200 Subject: [PATCH 08/32] Fix build matrix definition --- .github/workflows/publish_images.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 352022bf..428088aa 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -35,14 +35,15 @@ env: jobs: build-and-push-image: runs-on: ubuntu-latest - matrix: - image_name: - - python - python_version: - - 3.9 - - 3.10 - - 3.11 - - 3.12 + strategy: + matrix: + image_name: + - python + python_version: + - 3.9 + - 3.10 + - 3.11 + - 3.12 # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. From 6f683737c825f8e789af8d0b67406d9c599775c7 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:42:30 +0200 Subject: [PATCH 09/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 428088aa..ce552c2e 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -44,6 +44,9 @@ jobs: - 3.10 - 3.11 - 3.12 + include: + - image_name: hannah + python_version: 3.12 # THis is ignored # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. @@ -70,7 +73,8 @@ jobs: id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ matrix.image_name }}_${{matrix.python_version }} + images: ${{ env.REGISTRY }}/${{ matrix.image_name }}${{ matrix.image_name == 'python' && '_${{ matrix.python_version }}' || '' }} + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. From ae37ba214d7a9cf776752123015fc3ce2f6b18e0 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:57:16 +0200 Subject: [PATCH 10/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 15 ++++++++++++--- Dockerfile | 7 +++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index ce552c2e..2988b7b3 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - image_name: + target: - python python_version: - 3.9 @@ -45,7 +45,7 @@ jobs: - 3.11 - 3.12 include: - - image_name: hannah + - target: hannah python_version: 3.12 # THis is ignored @@ -69,11 +69,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Set image name + id: set_image_name + run: echo "image_name=${{ matrix.target }}${{ matrix.target == 'python' && '_${{ matrix.target }}' || '' }}" >> $GITHUB_ENV + + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ matrix.image_name }}${{ matrix.image_name == 'python' && '_${{ matrix.python_version }}' || '' }} + images: ${{ env.REGISTRY }}/${{ env.image_name }}" || '' }} # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. @@ -86,3 +91,7 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + python_version=${{ matrix.python_version }} + target=${{ matrix.target }} + diff --git a/Dockerfile b/Dockerfile index 7b9434b1..f536a2e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,8 +35,11 @@ FROM python:${PYTHON_VERSION} as python FROM ${target} -RUN apt-get update -y && apt-get -y install git mesa-utils python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3 - +RUN if [ "$target" == hannah ] || [ "$IMAGE_NAME" = "mlonmcu" ]; then\ + apt-get update -y && apt-get -y install git mesa-utils python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3 \ + else \ + apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential \ + fi # Install poetry using recommended method RUN pip install poetry From e4a9a35e6ceefe9ebf73d5ecc087aaae569dbf63 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 18:58:43 +0200 Subject: [PATCH 11/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 2988b7b3..7e20022f 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -78,7 +78,7 @@ jobs: id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ env.image_name }}" || '' }} + images: ${{ env.REGISTRY }}/${{ env.image_name }}" # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. From d2c89e975fa5b2c92ca72c582710429573152f37 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:00:25 +0200 Subject: [PATCH 12/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 7e20022f..c57c2668 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -71,14 +71,14 @@ jobs: # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Set image name id: set_image_name - run: echo "image_name=${{ matrix.target }}${{ matrix.target == 'python' && '_${{ matrix.target }}' || '' }}" >> $GITHUB_ENV + run: echo "target_name=${{ matrix.target }}${{ matrix.target == 'python' && '_${{ matrix.target }}' || '' }}" >> $GITHUB_ENV - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ env.image_name }}" + images: ${{ env.REGISTRY }}/${{ env.target_name }} # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. From 8c60b74dc3376e0aca91aa50de876a4bdf097e3f Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:01:16 +0200 Subject: [PATCH 13/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index c57c2668..cf59a109 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -71,14 +71,14 @@ jobs: # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Set image name id: set_image_name - run: echo "target_name=${{ matrix.target }}${{ matrix.target == 'python' && '_${{ matrix.target }}' || '' }}" >> $GITHUB_ENV + run: echo "image_name=${{ matrix.target }}${{ matrix.target == 'python' && '_${{ matrix.target }}' || '' }}" >> $GITHUB_ENV - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ env.target_name }} + images: ${{ env.REGISTRY }}/${{ env.image_name }} # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. From d742d66399db4d94494edbf35c9fdf290b058e91 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:03:25 +0200 Subject: [PATCH 14/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index cf59a109..593b6418 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -71,8 +71,12 @@ jobs: # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Set image name id: set_image_name - run: echo "image_name=${{ matrix.target }}${{ matrix.target == 'python' && '_${{ matrix.target }}' || '' }}" >> $GITHUB_ENV - + run: | + if [ "${{ matrix.target }}" = "python" ]; then + echo "image_name=${{ matrix.target }}_${{ matrix.python_version }}" >> $GITHUB_ENV + else + echo "image_name=${{ matrix.target }}" >> $GITHUB_ENV + fi - name: Extract metadata (tags, labels) for Docker id: meta From 305bac10320b55b7fa662298b0654cb6f3b227f1 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:04:48 +0200 Subject: [PATCH 15/32] Build hannah images without python version --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f536a2e5..7fcc3518 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,9 +36,9 @@ FROM ${target} RUN if [ "$target" == hannah ] || [ "$IMAGE_NAME" = "mlonmcu" ]; then\ - apt-get update -y && apt-get -y install git mesa-utils python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3 \ + apt-get update -y && apt-get -y install git mesa-utils python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3; \ else \ - apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential \ + apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential; \ fi # Install poetry using recommended method From e1ebc942f636fa7a74f6492155fa94ce48ee1d93 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:08:43 +0200 Subject: [PATCH 16/32] Build hannah images without python version --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7fcc3518..33440627 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,8 +35,8 @@ FROM python:${PYTHON_VERSION} as python FROM ${target} -RUN if [ "$target" == hannah ] || [ "$IMAGE_NAME" = "mlonmcu" ]; then\ - apt-get update -y && apt-get -y install git mesa-utils python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3; \ +RUN if [ "$target" == hannah ] || [ "$target" = "mlonmcu" ]; then\ + apt-get update -y && apt-get -y install git mesa-utils python3 python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3; \ else \ apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential; \ fi From a885ea80aeaf4b4f389d4fc6eb7d10c0c6833448 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:09:03 +0200 Subject: [PATCH 17/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 593b6418..2a9ff9b0 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -44,9 +44,9 @@ jobs: - 3.10 - 3.11 - 3.12 - include: - - target: hannah - python_version: 3.12 # THis is ignored + #include: + # - target: hannah + # python_version: 3.12 # THis is ignored # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. From 8974241112efa11d1d0e2662a540d17926ac286e Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Thu, 22 Aug 2024 19:11:41 +0200 Subject: [PATCH 18/32] Build hannah images without python version --- .github/workflows/publish_images.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 2a9ff9b0..057a07e8 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -40,10 +40,10 @@ jobs: target: - python python_version: - - 3.9 - - 3.10 - - 3.11 - - 3.12 + - '3.9' + - '3.10' + - '3.11' + - '3.12' #include: # - target: hannah # python_version: 3.12 # THis is ignored From 86fe84e3a36085198a0d3e19416b1b8735cb8f74 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:24:58 +0200 Subject: [PATCH 19/32] Correct python version --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33440627..db3d99f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ ARG target="hannah" # ARG for Python version, defaulting to 3.12 only used if python target is selected -ARG PYTHON_VERSION=3.12 +ARG python_version=3.12 FROM ubuntu:22.04 as hannah @@ -29,7 +29,7 @@ FROM tumeda/mlonmcu-bench:latest as mlonmcu # Use specified Python version as the base image -FROM python:${PYTHON_VERSION} as python +FROM python:${python_version} as python FROM ${target} From 7a4db4e1c57e4a162b47ecedf815771bfb532771 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:26:00 +0200 Subject: [PATCH 20/32] Reactivate ubuntu based base image --- .github/workflows/publish_images.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 057a07e8..9c1bcf75 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -44,9 +44,9 @@ jobs: - '3.10' - '3.11' - '3.12' - #include: - # - target: hannah - # python_version: 3.12 # THis is ignored + include: + - target: hannah + python_version: 3.12 # THis is ignored # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. From b4c5cb23b3fee18b148f9c697465507f61208bd8 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:27:59 +0200 Subject: [PATCH 21/32] Disable 3.12 builds --- .github/workflows/publish_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 9c1bcf75..e6387a35 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -43,7 +43,7 @@ jobs: - '3.9' - '3.10' - '3.11' - - '3.12' + #- '3.12' include: - target: hannah python_version: 3.12 # THis is ignored From f4f2915de2bbf11e9dea894e2839c1c75462d46b Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:34:44 +0200 Subject: [PATCH 22/32] Disable 3.12 builds --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index db3d99f6..d2e945b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,7 @@ RUN if [ "$target" == hannah ] || [ "$target" = "mlonmcu" ]; then\ fi # Install poetry using recommended method -RUN pip install poetry +RUN pip3 install poetry # Copy only requirements to cache them in docker layer From 0460af3463fff48a92e68067c4130ab5bc53d60b Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:36:15 +0200 Subject: [PATCH 23/32] Disable hannah build again --- .github/workflows/publish_images.yml | 6 +++--- Dockerfile | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index e6387a35..00b92f4a 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -44,9 +44,9 @@ jobs: - '3.10' - '3.11' #- '3.12' - include: - - target: hannah - python_version: 3.12 # THis is ignored + #include: + # - target: hannah + # python_version: 3.12 # THis is ignored # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. diff --git a/Dockerfile b/Dockerfile index d2e945b7..9aaba4b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,14 +24,9 @@ ARG target="hannah" ARG python_version=3.12 FROM ubuntu:22.04 as hannah - FROM tumeda/mlonmcu-bench:latest as mlonmcu - - -# Use specified Python version as the base image FROM python:${python_version} as python - FROM ${target} From c53efc2f38caf3f7916965be346f0dfdd6c6d0ef Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:43:26 +0200 Subject: [PATCH 24/32] Make switch in dockerfile posix compliant --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9aaba4b9..586beda2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,8 +29,7 @@ FROM python:${python_version} as python FROM ${target} - -RUN if [ "$target" == hannah ] || [ "$target" = "mlonmcu" ]; then\ +RUN if [ "$target" = "hannah" ] || [ "$target" = "mlonmcu" ]; then\ apt-get update -y && apt-get -y install git mesa-utils python3 python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3; \ else \ apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential; \ From 90862f8cba9b89acfef80d5382de1acb6d2d4c47 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 09:44:58 +0200 Subject: [PATCH 25/32] Enable docker again --- .github/workflows/publish_images.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 00b92f4a..e6387a35 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -44,9 +44,9 @@ jobs: - '3.10' - '3.11' #- '3.12' - #include: - # - target: hannah - # python_version: 3.12 # THis is ignored + include: + - target: hannah + python_version: 3.12 # THis is ignored # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. From 22c268067c3200cf47a5a999b97efaa9f60e03b6 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 10:14:06 +0200 Subject: [PATCH 26/32] Fix docker file --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 586beda2..d2add4ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,14 +29,19 @@ FROM python:${python_version} as python FROM ${target} +ARG python_version +ARG target + RUN if [ "$target" = "hannah" ] || [ "$target" = "mlonmcu" ]; then\ apt-get update -y && apt-get -y install git mesa-utils python3 python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3; \ else \ apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential; \ fi +RUN echo "Target: $target" + # Install poetry using recommended method -RUN pip3 install poetry +RUN pip install poetry # Copy only requirements to cache them in docker layer From 222eaddda73064e295ab66a89a56d96a7832787d Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 10:43:12 +0200 Subject: [PATCH 27/32] Set label manually --- .github/workflows/publish_images.yml | 10 ++-------- Dockerfile | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index e6387a35..63717276 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -78,12 +78,7 @@ jobs: echo "image_name=${{ matrix.target }}" >> $GITHUB_ENV fi - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.REGISTRY }}/${{ env.image_name }} - + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. @@ -93,8 +88,7 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ env.image_name }}:latest build-args: | python_version=${{ matrix.python_version }} target=${{ matrix.target }} diff --git a/Dockerfile b/Dockerfile index d2add4ea..0db19548 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ FROM python:${python_version} as python FROM ${target} +# These need to be set here again, as the FROM directive resets the ARGs on use ARG python_version ARG target From e008a5fe7e55aa620ed7f9dcee30b2989e1df5ea Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 13:37:45 +0200 Subject: [PATCH 28/32] Use correct registry --- .github/workflows/publish_images.yml | 2 +- Dockerfile | 1 - hannah/train.py | 3 --- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 63717276..3abaac41 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -88,7 +88,7 @@ jobs: with: context: . push: true - tags: ${{ env.image_name }}:latest + tags: ${{ env.REGISTRY }}/${{ env.image_name }}:latest build-args: | python_version=${{ matrix.python_version }} target=${{ matrix.target }} diff --git a/Dockerfile b/Dockerfile index 0db19548..ab4379bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,6 @@ RUN if [ "$target" = "hannah" ] || [ "$target" = "mlonmcu" ]; then\ apt-get update -y && apt-get -y install git mesa-utils libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential; \ fi -RUN echo "Target: $target" # Install poetry using recommended method RUN pip install poetry diff --git a/hannah/train.py b/hannah/train.py index 0d89ad32..3297a443 100644 --- a/hannah/train.py +++ b/hannah/train.py @@ -120,9 +120,6 @@ def train( logger.append(CSVLogger(".", version="logs", name="")) logger.append(JSONLogger(".", version="logs", name="")) - # if DVCLIVE_AVAILABLE: - # logger.append(DVCLogger()) - callbacks = [] callbacks.extend(list(common_callbacks(config))) From fd6480ed234fef475dcf15060edcd1f57abe75a3 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 13:46:07 +0200 Subject: [PATCH 29/32] Use correct registry --- .github/workflows/publish_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index 3abaac41..c7781e48 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -88,7 +88,7 @@ jobs: with: context: . push: true - tags: ${{ env.REGISTRY }}/${{ env.image_name }}:latest + tags: ${{ env.REGISTRY }}/${{ github.repository }}_${{ env.image_name }}:latest build-args: | python_version=${{ matrix.python_version }} target=${{ matrix.target }} From 6177a878ef50af9f3989cbf452e7b915ed868bf1 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 14:21:23 +0200 Subject: [PATCH 30/32] Add opencontainer labels --- .github/workflows/publish_images.yml | 1 + Dockerfile | 1 + Dockerfile.python3 | 44 ---------------------------- 3 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 Dockerfile.python3 diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index c7781e48..86b46541 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -89,6 +89,7 @@ jobs: context: . push: true tags: ${{ env.REGISTRY }}/${{ github.repository }}_${{ env.image_name }}:latest + labels: org.opencontainers.image.source=${{ github.repositoryUrl }}, org.opencontainers.image.version=${{ github.sha }} build-args: | python_version=${{ matrix.python_version }} target=${{ matrix.target }} diff --git a/Dockerfile b/Dockerfile index ab4379bd..6d0f6495 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,3 +52,4 @@ COPY poetry.lock pyproject.toml /deps/ # Install dependencies RUN poetry config virtualenvs.create false \ && poetry install --no-interaction --no-ansi --all-extras --no-root + diff --git a/Dockerfile.python3 b/Dockerfile.python3 deleted file mode 100644 index 4e08fb96..00000000 --- a/Dockerfile.python3 +++ /dev/null @@ -1,44 +0,0 @@ -# ARG for Python version, defaulting to 3.12 -ARG PYTHON_VERSION=3.12 - -# Use specified Python version as the base image -FROM python:${PYTHON_VERSION} - -# Set working directory -WORKDIR /data - -# Set environment variables -ENV PIP_CACHE_DIR="/data/.cache/pip" \ - POETRY_HOME="/data/.poetry" \ - POETRY_CACHE_DIR="/data/.cache/pypoetry" \ - GIT_SUBMODULE_STRATEGY="recursive" \ - DEBIAN_FRONTEND="noninteractive" - -# Install system dependencies -RUN apt-get update && apt-get install -y \ - git \ - mesa-utils \ - python3-dev \ - libblas-dev \ - liblapack-dev \ - libsndfile1-dev \ - libsox-dev \ - cmake \ - ninja-build \ - && rm -rf /var/lib/apt/lists/* - -# Install Poetry -RUN curl -sSL https://install.python-poetry.org/ | python3 - -ENV PATH="${POETRY_HOME}/bin:${PATH}" - -# Copy project files -# COPY hannah/pyproject.toml hannah/poetry.lock* ./ - -COPY hannah/ ./ - -# Configure Poetry and install dependencies -RUN poetry config installer.max-workers 10 && \ - poetry install --with dev - -# Show limits (this will be executed when the container runs) -CMD ["sh", "-c", "ulimit -a && /bin/bash"] From 2cabe9df12cf234407635eebaf9cce4d02a59387 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 15:34:59 +0200 Subject: [PATCH 31/32] Delete poetry cache from images --- .gitlab-ci.yml | 38 +++----------------------------------- Dockerfile | 6 +++++- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f10f1a7..967930f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,21 +53,9 @@ test_prebuilt_docker: dependencies: [] -build_testcontainers: - stage: build - image: gitlab/gitlab-runner:latest - tags: - - dind - before_script: - - apk add --no-cache bash - script: - - bash ./build_testcontainer.sh all - allow_failure: false - when: manual - test_python_39: stage: test - image: es-git-registry.cs.uni-tuebingen.de/es/ai/hannah/hannah/testing/python:3.9 + image: ghcr.io/ekut-es/hannah_python_3.9:latest script: - set -e - poetry config installer.max-workers 10 @@ -84,29 +72,9 @@ test_python_39: - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - when: manual -#test_tvm: -# stage: test -# image: ubuntu:22.04 -# script: -# - set -e -# - apt-get install -y llvm-dev libclang-dev g++ python-is-python3 -# - poetry config installer.max-workers 10 -# - poetry run external/hannah-tvm/scripts/install_full.sh -# - poetry install -E tvm -E vision -# - poetry run python -m pytest -v --cov=hannah --cov external/hannah-tvm test --integration -# tags: -# - docker -# interruptible: true -# allow_failure: false -# rules: -# - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH -# cache: -# paths: -# - .cache/ - test_python_310: stage: test - image: es-git-registry.cs.uni-tuebingen.de/es/ai/hannah/hannah/testing/python:3.10 + image: ghcr.io/ekut-es/hannah_python_3.10:latest script: - set -e - poetry config installer.max-workers 10 @@ -137,7 +105,7 @@ test_python_310: test_python_311: stage: test - image: es-git-registry.cs.uni-tuebingen.de/es/ai/hannah/hannah/es/ai/hannah/hannah/testing/python:3.11 + image: ghcr.io/ekut-es/hannah_python_3.11:latest script: - set -e - poetry config installer.max-workers 10 diff --git a/Dockerfile b/Dockerfile index 6d0f6495..194296fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,9 @@ FROM ${target} ARG python_version ARG target +ENV POETRY_CACHE_DIR="/tmp/poetry_cache" + + RUN if [ "$target" = "hannah" ] || [ "$target" = "mlonmcu" ]; then\ apt-get update -y && apt-get -y install git mesa-utils python3 python3-pip python3-dev libblas-dev liblapack-dev libsndfile1-dev libsox-dev cmake ninja-build curl build-essential python-is-python3; \ else \ @@ -51,5 +54,6 @@ COPY poetry.lock pyproject.toml /deps/ # Install dependencies RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi --all-extras --no-root + && poetry install --no-interaction --no-ansi --all-extras --no-root \ + && rm -rf $POETRY_CACHE_DIR From 4f0650d226c1b0fca087eb3fd898229ddb48c5f0 Mon Sep 17 00:00:00 2001 From: Christoph Gerum Date: Fri, 23 Aug 2024 16:01:44 +0200 Subject: [PATCH 32/32] Install globally in docker --- .gitlab-ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 967930f7..b5aefd79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,7 @@ variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" POETRY_HOME: "$CI_PROJECT_DIR/.poetry" POETRY_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pypoetry" + POETRY_VIRTUALENVS_CREATE: false GIT_SUBMODULE_STRATEGY: recursive DEBIAN_FRONTEND: "noninteractive" @@ -36,12 +37,6 @@ cache: test_prebuilt_docker: stage: test image: cgerum/hannah:latest - before_script: - - export POETRY_HOME=/root/.local - - export PATH=${POETRY_HOME}/bin:${PATH} - - poetry config installer.max-workers 10 - - poetry install -E vision - - ulimit -a script: - set -e - poetry run python3 -m pytest -v --cov=hannah test hannah