fix(worker): 修复 dedup fingerprint JSON 序列化失败 - np.float32 转原生 float
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1566h47m10s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1566h47m12s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1566h47m14s
CI/CD Pipeline / Build Production Runtime Images (pull_request) Failing after 1566h47m15s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Failing after 1566h47m15s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1567h18m47s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1566h47m10s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1566h47m12s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1566h47m14s
CI/CD Pipeline / Build Production Runtime Images (pull_request) Failing after 1566h47m15s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Failing after 1566h47m15s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1567h18m47s
根因:cv2.normalize() 返回 np.float32 数组,color_histograms 直接存进 dict 后 SQLAlchemy JSON 序列化时报 'float32 is not JSON serializable' 修复:VideoFingerprint.to_dict() 中统一转 Python 原生类型 - color_histograms: np.float32 → float - duration: 统一转 float - resolution: np.int32 → int
This commit is contained in:
Regular → Executable
+7
-3
@@ -93,12 +93,16 @@ class VideoFingerprint:
|
||||
resolution: tuple[int, int]
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
# 注意:color_histograms 里的值可能是 np.float32(来自 cv2.normalize),
|
||||
# 直接存进 dict 后 SQLAlchemy JSON 序列化会报 "float32 is not JSON serializable"。
|
||||
# 这里统一转成 Python 原生 float。
|
||||
native_histograms = [[float(v) for v in hist] for hist in self.color_histograms]
|
||||
return {
|
||||
"md5": self.md5,
|
||||
"keyframe_phashes": self.keyframe_phashes,
|
||||
"color_histograms": self.color_histograms,
|
||||
"duration": self.duration,
|
||||
"resolution": list(self.resolution),
|
||||
"color_histograms": native_histograms,
|
||||
"duration": float(self.duration),
|
||||
"resolution": [int(self.resolution[0]), int(self.resolution[1])],
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user