From 2cc1896225cec667893068a3be5d8e7d09043af5 Mon Sep 17 00:00:00 2001
From: Pshysimon <caixiaomeng2@huawei.com>
Date: Sat, 12 Apr 2025 16:44:11 +0800
Subject: [PATCH] fix atune-adm analyse failed problem

---
 analysis/optimizer/app_characterization.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/analysis/optimizer/app_characterization.py b/analysis/optimizer/app_characterization.py
index 80b6752..738320f 100644
--- a/analysis/optimizer/app_characterization.py
+++ b/analysis/optimizer/app_characterization.py
@@ -202,16 +202,9 @@ class AppCharacterization(WorkloadCharacterization):
         :param feature_selection:  whether to perform feature extraction
         :param consider_perf: whether to consider perf indicators
         """
-        if consider_perf == None:
-            consider_perf = self.consider_perf
-            
-        data_features = self.get_consider_perf(consider_perf)
-        
         cpu_exist, mem_exist, net_quality_exist, net_io_exist, disk_io_exist = self.bottleneck.search_bottleneck(data)
         bottleneck_binary = (int(cpu_exist) << 4) | (int(mem_exist) << 3) | (int(net_quality_exist) << 2) | (int(net_io_exist) << 1) | int(disk_io_exist)
 
-        data = data[data_features]
-
         tencoder_path = os.path.join(self.model_path, "tencoder.pkl")
         aencoder_path = os.path.join(self.model_path, "aencoder.pkl")
         scaler_path = os.path.join(self.model_path, "scaler.pkl")
@@ -226,6 +219,13 @@ class AppCharacterization(WorkloadCharacterization):
         type_model_clf = joblib.load(type_model_path)
         app_model_clf = joblib.load(app_model_path)
 
+        if consider_perf is None: 
+            consider_perf = (len(self.scaler.mean_) == len(data.columns))
+
+        data_features = self.get_consider_perf(consider_perf)
+
+        data = data[data_features]
+
         data = self.scaler.transform(data)
 
         if feature_selection:
@@ -290,4 +290,4 @@ class AppCharacterization(WorkloadCharacterization):
         confidence = prediction[1] / len(result)
         if confidence > 0.5:
             return bottleneck_binary, prediction[0], confidence
-        return bottleneck_binary, "default", confidence
\ No newline at end of file
+        return bottleneck_binary, "default", confidence
-- 
2.27.0

