From 9465cd9f9d6e08c77730e0816f3a3d0458df59a1 Mon Sep 17 00:00:00 2001 From: Natan Yellin Date: Sat, 15 Jun 2024 14:43:53 +0300 Subject: [PATCH 1/2] Fix version command on dev builds (#291) * Remove broken workflow for bumping version * Make version correct on dev builds --- .github/workflows/update-code-version.yml | 40 ----------------------- robusta_krr/__init__.py | 2 +- robusta_krr/utils/version.py | 32 +++++++++++++++--- 3 files changed, 29 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/update-code-version.yml diff --git a/.github/workflows/update-code-version.yml b/.github/workflows/update-code-version.yml deleted file mode 100644 index 91ba7819..00000000 --- a/.github/workflows/update-code-version.yml +++ /dev/null @@ -1,40 +0,0 @@ -# @format - -name: Update Version - -on: - push: - tags: - - "v*" - -jobs: - update-version: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Extract version from tag - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - - - name: Fetch all branches - run: git fetch --all - - - name: Select main branch - run: git checkout origin/main - - - name: Update version in pyproject.toml - run: | - sed -i "s/version = \".*\"/version = \"$VERSION\"/" pyproject.toml - - - name: Update version in robusta_krr/__init__.py - run: | - sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" robusta_krr/__init__.py - - - name: Commit and push - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add pyproject.toml robusta_krr/__init__.py - git commit -m "Update version to $VERSION" && git push diff --git a/robusta_krr/__init__.py b/robusta_krr/__init__.py index 4866168b..c428657b 100644 --- a/robusta_krr/__init__.py +++ b/robusta_krr/__init__.py @@ -1,4 +1,4 @@ from .main import run -__version__ = "1.8.2-dev" +__version__ = "dev" __all__ = ["run", "__version__"] diff --git a/robusta_krr/utils/version.py b/robusta_krr/utils/version.py index d7b5df7f..47f81c55 100644 --- a/robusta_krr/utils/version.py +++ b/robusta_krr/utils/version.py @@ -1,12 +1,36 @@ -import robusta_krr -import requests import asyncio -from typing import Optional +import os +import subprocess +import sys from concurrent.futures import ThreadPoolExecutor +from typing import Optional + +import requests + +import robusta_krr def get_version() -> str: - return robusta_krr.__version__ + # the version string was patched by a release - return __version__ which will be correct + if robusta_krr.__version__ != "dev": + return robusta_krr.__version__ + + # we are running from an unreleased dev version + try: + # Get the latest git tag + tag = subprocess.check_output(["git", "describe", "--tags"]).decode().strip() + + # Get the current branch name + branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode().strip() + + # Check if there are uncommitted changes + status = subprocess.check_output(["git", "status", "--porcelain"]).decode().strip() + dirty = "-dirty" if status else "" + + return f"{tag}-{branch}{dirty}" + + except Exception: + return robusta_krr.__version__ # Synchronous function to fetch the latest release version from GitHub API From ab85be83a1801599eea24ef3421abd448c341d1a Mon Sep 17 00:00:00 2001 From: Natan Yellin Date: Sat, 15 Jun 2024 14:45:05 +0300 Subject: [PATCH 2/2] Linkify README.md (#288) --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6815c0d1..80895909 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ _View instructions for: [Seeing recommendations in a UI](#free-ui-for-krr-recomm - **No Agent Required**: Run a CLI tool on your local machine for immediate results. (Or run in-cluster for weekly [Slack reports](#slack-integration).) - **Prometheus Integration**: Get recommendations based on the data you already have -- **Explainability**: Understand how recommendations were calculated +- **Explainability**: [Understand how recommendations were calculated with explanation graphs](#free-krr-ui-on-robusta-saas) - **Extensible Strategies**: Easily create and use your own strategies for calculating resource recommendations. - **Free SaaS Platform**: See why KRR recommends what it does, by using the [free Robusta SaaS platform](https://platform.robusta.dev/signup/?utm_source=github&utm_medium=krr-readme). - **Future Support**: Upcoming versions will support custom resources (e.g. GPUs) and custom metrics. @@ -106,15 +106,15 @@ Read more about [how KRR works](#how-krr-works) | Resource Recommendations 💡 | ✅ CPU/Memory requests and limits | ✅ CPU/Memory requests and limits | | Installation Location 🌍 | ✅ Not required to be installed inside the cluster, can be used on your own device, connected to a cluster | ❌ Must be installed inside the cluster | | Workload Configuration 🔧 | ✅ No need to configure a VPA object for each workload | ❌ Requires VPA object configuration for each workload | -| Immediate Results ⚡ | ✅ Gets results immediately (given Prometheus is running) | ❌ Requires time to gather data and provide recommendations | +| Immediate Results ⚡ | ✅ Gets results immediately (given Prometheus is running) | ❌ Requires time to gather data and provide recommendations | | Reporting 📊 | ✅ Detailed CLI Report, web UI in [Robusta.dev](https://home.robusta.dev/) | ❌ Not supported | | Extensibility 🔧 | ✅ Add your own strategies with few lines of Python | :warning: Limited extensibility | -| Explainability 📖 | ✅ See graphs explaining the recommendations | ❌ Not supported | +| Explainability 📖 | ✅ [See graphs explaining the recommendations](#free-krr-ui-on-robusta-saas) | ❌ Not supported | | Custom Metrics 📏 | 🔄 Support in future versions | ❌ Not supported | | Custom Resources 🎛️ | 🔄 Support in future versions (e.g., GPU) | ❌ Not supported | | Autoscaling 🔀 | 🔄 Support in future versions | ✅ Automatic application of recommendations | -| Default History 🕒 | 14 days | 8 days | -| Supports HPA 🔥 | ✅ Enable using `--allow-hpa` flag | ❌ Not supported | +| Default History 🕒 | 14 days | 8 days | +| Supports HPA 🔥 | ✅ Enable using `--allow-hpa` flag | ❌ Not supported |