Browse Source

fix(db): 修复模型查询字段错误

- 将 model_cfg 表中的 id 字段更正为 model_id
- 将 model_version 表中的 id 字段更正为 model_id
- 确保模型查询逻辑使用正确的字段名

chore(docker): 更新 Debian 镜像源配置

- 替换基础镜像中的 APT 源为清华大学镜像站
- 在 builder 和 runtime 阶段均配置 bookworm 版本的清华源
- 优化源列表生成方式,提高可读性和维护性
- 保留 libodbc1 安装注释说明
pull/35/head
chenjiale 1 month ago
parent
commit
993238b8d7
  1. 16
      Dockerfile
  2. 4
      PCA_Test.py

16
Dockerfile

@ -3,8 +3,11 @@
# ======================
FROM python:3.10.16-slim AS builder
RUN sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources
# 使用清华源(Debian 12 Bookworm)
RUN printf "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware\n\
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n\
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware\n" \
> /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@ -23,10 +26,13 @@ RUN pip install --no-cache-dir --prefix=/python_install \
# ======================
FROM python:3.10.16-slim
RUN sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources
# 使用清华源(HTTPS)
RUN printf "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware\n\
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n\
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware\n" \
> /etc/apt/sources.list
# ⭐ pyodbc 运行必须安装 libodbc1(提供 libodbc.so.2)
# pyodbc 必须安装 libodbc1(提供 libodbc.so.2)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libodbc1 unixodbc \

4
PCA_Test.py

@ -189,13 +189,13 @@ class MySQL:
self.conn.close()
def get_model_by_ID(model_id, version="v-test"):
ms = MySQL(host=config._SQL_IP, user="root", pwd="powerSIS#123", database="alert")
resList = ms.ExecQuery(f"SELECT Model_info FROM model_cfg where id={model_id}")
resList = ms.ExecQuery(f"SELECT Model_info FROM model_cfg where model_id={model_id}")
return json.loads(resList[0][0])
def get_model_by_id_and_version(model_id, version):
ms = MySQL(host=config._SQL_IP, user="root", pwd="powerSIS#123", database="alert")
resList = ms.ExecQuery(f"SELECT Model_info FROM model_version where id={model_id} and version='{version}'")
resList = ms.ExecQuery(f"SELECT Model_info FROM model_version where model_id={model_id} and version='{version}'")
return json.loads(resList[0][0])
def pca(model, Data_origin):

Loading…
Cancel
Save