rabbit: 2.3.1 -> 2.3.2

This commit is contained in:
mivorasu 2025-07-31 19:57:32 +08:00
parent ed33ba16ce
commit f9da1e8966
2 changed files with 20 additions and 69 deletions

View File

@ -1,47 +0,0 @@
From 3488de815355051d2e369c7fe48a35dabf695cfc Mon Sep 17 00:00:00 2001
From: Pol Dellaiera <pol.dellaiera@protonmail.com>
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

View File

@ -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"