From 404595c57b9c30e56792ea18f3e0c3ef3dd45407 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 3 Mar 2024 22:00:34 +0300 Subject: [PATCH 1/3] prometheus-api-client: init at 0.5.5 --- .../prometheus-api-client/default.nix | 62 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 64 insertions(+) create mode 100644 pkgs/development/python-modules/prometheus-api-client/default.nix diff --git a/pkgs/development/python-modules/prometheus-api-client/default.nix b/pkgs/development/python-modules/prometheus-api-client/default.nix new file mode 100644 index 000000000000..842b4c0b22ab --- /dev/null +++ b/pkgs/development/python-modules/prometheus-api-client/default.nix @@ -0,0 +1,62 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pytestCheckHook +, dateparser +, httmock +, matplotlib +, numpy +, pandas +, requests +}: + +buildPythonPackage rec { + pname = "prometheus-api-client"; + version = "0.5.5"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "4n4nd"; + repo = "prometheus-api-client-python"; + rev = "refs/tags/v${version}"; + hash = "sha256-tUu0+ZUOFxBCj//lHhNm88rhFbS01j1x508+nqIkCfQ="; + }; + + propagatedBuildInputs = [ + dateparser + matplotlib + numpy + pandas + requests + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + checkInputs = [ + httmock + ]; + + disabledTestPaths = [ + "tests/test_prometheus_connect.py" + ]; + + pythonImportsCheck = [ + "prometheus_api_client" + ]; + + + meta = with lib; { + description = "A Python wrapper for the Prometheus HTTP API"; + longDescription = '' + The prometheus-api-client library consists of multiple modules which + assist in connecting to a Prometheus host, fetching the required metrics + and performing various aggregation operations on the time series data. + ''; + homepage = "https://github.com/4n4nd/prometheus-api-client-python"; + changelog = "https://github.com/4n4nd/prometheus-api-client-python/blob/${src.rev}/CHANGELOG.md"; + license = licenses.mit; + maintainers = with maintainers; [ azahi ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 86faee8e0e70..a13363d608d3 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10035,6 +10035,8 @@ self: super: with self; { progress = callPackage ../development/python-modules/progress { }; + prometheus-api-client = callPackage ../development/python-modules/prometheus-api-client { }; + prometheus-client = callPackage ../development/python-modules/prometheus-client { }; prometheus-flask-exporter = callPackage ../development/python-modules/prometheus-flask-exporter { }; From 9a3b0ba3b5548d62dce7fe260db5e7ff389119fa Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 3 Mar 2024 22:01:23 +0300 Subject: [PATCH 2/3] prometrix: init at unstable-2024-02-20 --- .../python-modules/prometrix/default.nix | 62 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 64 insertions(+) create mode 100644 pkgs/development/python-modules/prometrix/default.nix diff --git a/pkgs/development/python-modules/prometrix/default.nix b/pkgs/development/python-modules/prometrix/default.nix new file mode 100644 index 000000000000..58b3ac27361e --- /dev/null +++ b/pkgs/development/python-modules/prometrix/default.nix @@ -0,0 +1,62 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, boto3 +, botocore +, dateparser +, matplotlib +, numpy +, pandas +, poetry-core +, prometheus-api-client +, pydantic_1 +, requests +}: + +buildPythonPackage rec { + pname = "prometrix"; + version = "unstable-2024-02-20"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "robusta-dev"; + repo = "prometrix"; + rev = "ab2dad2192ed3df91c1a25446a4f54b8f2f6742f"; + hash = "sha256-/72Qkd2BojYgiQi5rq7dVsEje7M0aQQXhenvIM7lSy4="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail 'pydantic = "^1.8.1"' 'pydantic = "*"' + ''; + + propagatedBuildInputs = [ + boto3 + botocore + dateparser + matplotlib + numpy + pandas + prometheus-api-client + pydantic_1 + requests + ]; + + nativeBuildInputs = [ + poetry-core + ]; + + pythonImportsCheck = [ + "prometrix" + ]; + + meta = with lib; { + description = "Unified Prometheus client"; + longDescription = '' + This Python package provides a unified Prometheus client that can be used + to connect to and query various types of Prometheus instances. + ''; + license = licenses.mit; + maintainers = with maintainers; [ azahi ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index a13363d608d3..95e18058ac0a 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10041,6 +10041,8 @@ self: super: with self; { prometheus-flask-exporter = callPackage ../development/python-modules/prometheus-flask-exporter { }; + prometrix = callPackage ../development/python-modules/prometrix { }; + promise = callPackage ../development/python-modules/promise { }; prompt-toolkit = callPackage ../development/python-modules/prompt-toolkit { }; From c3b8f188d873df2ece23469c720647c267f79ee3 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 3 Mar 2024 22:01:53 +0300 Subject: [PATCH 3/3] krr: init at 1.7.0 --- pkgs/by-name/kr/krr/package.nix | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 pkgs/by-name/kr/krr/package.nix diff --git a/pkgs/by-name/kr/krr/package.nix b/pkgs/by-name/kr/krr/package.nix new file mode 100644 index 000000000000..d1819a749943 --- /dev/null +++ b/pkgs/by-name/kr/krr/package.nix @@ -0,0 +1,68 @@ +{ lib +, python3 +, fetchFromGitHub +, testers +, krr +}: + +python3.pkgs.buildPythonPackage rec { + pname = "krr"; + version = "1.7.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "robusta-dev"; + repo = "krr"; + rev = "refs/tags/v${version}"; + hash = "sha256-8K97v/8lsLqr88MSOT3peOy0GZp1so9GaipG/t2uR88="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail 'aiostream = "^0.4.5"' 'aiostream = "*"' \ + --replace-fail 'kubernetes = "^26.1.0"' 'kubernetes = "*"' \ + --replace-fail 'pydantic = "1.10.7"' 'pydantic = "*"' \ + --replace-fail 'typer = { extras = ["all"], version = "^0.7.0" }' 'typer = { extras = ["all"], version = "*" }' + ''; + + propagatedBuildInputs = with python3.pkgs; [ + aiostream + alive-progress + kubernetes + numpy + poetry-core + prometheus-api-client + prometrix + pydantic_1 + slack-sdk + typer + ] ++ typer.optional-dependencies.all; + + nativeCheckInputs = with python3.pkgs; [ + pytestCheckHook + ]; + + pythonImportsCheck = [ + "robusta_krr" + ]; + + passthru.tests.version = testers.testVersion { + package = krr; + command = "krr version"; + }; + + meta = with lib; { + description = "Prometheus-based Kubernetes resource recommendations"; + longDescription = '' + Robusta KRR (Kubernetes Resource Recommender) is a CLI tool for optimizing + resource allocation in Kubernetes clusters. It gathers Pod usage data from + Prometheus and recommends requests and limits for CPU and memory. This + reduces costs and improves performance. + ''; + homepage = "https://github.com/robusta-dev/krr"; + changelog = "https://github.com/robusta-dev/krr/releases/tag/v${src.rev}"; + license = licenses.mit; + maintainers = with lib.maintainers; [ azahi ]; + mainProgram = "krr"; + }; +}