diff --git a/pkgs/by-name/ra/rabbit/fix-file-loading.patch b/pkgs/by-name/ra/rabbit/fix-file-loading.patch deleted file mode 100644 index 3b5db5527fcc..000000000000 --- a/pkgs/by-name/ra/rabbit/fix-file-loading.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 3488de815355051d2e369c7fe48a35dabf695cfc Mon Sep 17 00:00:00 2001 -From: Pol Dellaiera -Date: Mon, 17 Mar 2025 16:52:25 +0100 -Subject: [PATCH] fix file loading - ---- - rabbit.py | 17 ++++++++--------- - 1 file changed, 8 insertions(+), 9 deletions(-) - -diff --git a/rabbit.py b/rabbit.py -index a1826d3..697c880 100644 ---- a/rabbit.py -+++ b/rabbit.py -@@ -9,6 +9,7 @@ from sklearn.ensemble import GradientBoostingClassifier - import joblib - import site - from tqdm import tqdm -+from importlib.resources import files - - import GenerateActivities as gat - import ExtractEvent as eev -@@ -59,15 +60,13 @@ def get_model(): - ''' - - model_file = 'bimbas.joblib' -- for dir in site.getsitepackages(): -- if dir.endswith('site-packages'): -- target_dir = dir -- else: -- target_dir = site.getsitepackages()[0] -- bot_identification_model = joblib.load(f'{target_dir}/{model_file}') -- # bot_identification_model = joblib.load(model_file) -- -- return(bot_identification_model) -+ try: -+ resource_path = files("rabbit").joinpath(model_file) -+ bot_identification_model = joblib.load(resource_path) -+ except Exception as e: -+ raise RuntimeError(f"Failed to load the model: {e}") -+ -+ return bot_identification_model - - def compute_confidence(probability_value): - ''' --- -2.48.1 - diff --git a/pkgs/by-name/ra/rabbit/package.nix b/pkgs/by-name/ra/rabbit/package.nix index d243b98b845b..e05fc323ee84 100644 --- a/pkgs/by-name/ra/rabbit/package.nix +++ b/pkgs/by-name/ra/rabbit/package.nix @@ -6,15 +6,18 @@ }: let - python3' = - let - packageOverrides = self: super: { - scikit-learn = super.scikit-learn.overridePythonAttrs (old: { + python3' = python3.override { + packageOverrides = self: super: { + scikit-learn = + let version = "1.5.2"; + in + super.scikit-learn.overridePythonAttrs (old: { + inherit version; src = fetchPypi { pname = "scikit_learn"; - version = "1.5.2"; + inherit version; hash = "sha256-tCN+17P90KSIJ5LmjvJUXVuqUKyju0WqffRoE4rY+U0="; }; @@ -23,36 +26,31 @@ let # - test_csr_polynomial_expansion_index_overflow[csr_array-False-True-3-2344] doCheck = false; }); - }; - in - python3.override { - inherit packageOverrides; - self = python3; }; -in -python3'.pkgs.buildPythonApplication rec { - pname = "rabbit"; + self = python3; + }; + # Make sure to check for which version of scikit-learn this project was built - # Currently version 2.3.1 is made with scikit-learn 1.5.2 + # Currently version 2.3.2 is made with scikit-learn 1.5.2 # Upgrading to newer versions of scikit-learn break the project - version = "2.3.1"; + version = "2.3.2"; +in +python3'.pkgs.buildPythonApplication { + pname = "rabbit"; + inherit version; pyproject = true; src = fetchFromGitHub { owner = "natarajan-chidambaram"; repo = "RABBIT"; tag = version; - hash = "sha256-QmP6yfVnlYoNVa4EUtKR9xbCnQW2V6deV0+hN9IGtic="; + hash = "sha256-icf42vqYPNH1v1wEv/MpqScqMUr/qDlcGoW9kPY2R6s="; }; - patches = [ - # Fix file loading, to be removed at the next bump. - # The author has been notified about the issue and currently working on it. - ./fix-file-loading.patch - ]; - pythonRelaxDeps = [ + "joblib" "numpy" + "requests" "scikit-learn" "scipy" "tqdm"