Browse Source

fix a model path type error

highing666 3 năm trước cách đây
mục cha
commit
7809128328
1 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 5 3
      app/controllers/equipment/fcu/early_start.py

+ 5 - 3
app/controllers/equipment/fcu/early_start.py

@@ -24,13 +24,15 @@ class EarlyStartTimeDTRBuilder:
     async def get_prediction(self, indoor_temp: float, outdoor_temp: float) -> float:
         try:
             model = load(self.model_path)
-        except (FileNotFoundError, IsADirectoryError):
+        except (FileNotFoundError, IsADirectoryError) as e:
+            logger.debug(e)
             return 0
 
         try:
             pre = model.predict([[indoor_temp, outdoor_temp]])
             pre_time = pre[0]
-        except (ValueError, IndexError):
+        except (ValueError, IndexError) as e:
+            logger.debug(e)
             pre_time = 0
 
         return pre_time
@@ -77,7 +79,7 @@ async def get_recommended_early_start_time(db: Session, project_id: str, space_i
 async def build_acatfc_early_start_prediction(params: ACATFCEarlyStartPredictionRequest, db: Session) -> float:
     model_path = model_path_early_start_dtr.get_path_by_device(db, params.device_id)
 
-    builder = EarlyStartTimeDTRBuilder(model_path)
+    builder = EarlyStartTimeDTRBuilder(model_path.model_path)
     hour = await builder.get_prediction(params.space_realtime_temperature, params.outdoor_realtime_temperature)
 
     return hour * 60