test
This commit is contained in:
1 parent
10d0f5bad8
commit
fcb70b85f4
3 files changed
+43
-16
No files matched your search
+5
-4
@@ -1,4 +1,4 @@
|
|||||||
FROM python:3.12-slim-bookworm
|
FROM python:3.12-slim-bookworm
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -10,11 +10,12 @@ RUN apt-get update \
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
COPY requirements.txt .
|
COPY backend/requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Copy application code
|
# Copy backend code and bundled Text2SQL schema docs
|
||||||
COPY . .
|
COPY backend/ .
|
||||||
|
COPY docs /app/docs
|
||||||
ENV ORACLE_HOME=/app/oracle_client/instantclient_19_31
|
ENV ORACLE_HOME=/app/oracle_client/instantclient_19_31
|
||||||
ENV LD_LIBRARY_PATH=/app/oracle_client/instantclient_19_31:/app/oracle_client:${LD_LIBRARY_PATH}
|
ENV LD_LIBRARY_PATH=/app/oracle_client/instantclient_19_31:/app/oracle_client:${LD_LIBRARY_PATH}
|
||||||
|
|
||||||
|
|||||||
@@ -154,15 +154,41 @@ class Text2SQLService:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
if cls._schema_text is None:
|
if cls._schema_text is None:
|
||||||
try:
|
schema_filename = '(表+字段).md'
|
||||||
# docs is at the project root: c:\Users\PC\Desktop\HX工作目录\hxops\hxops\docs
|
env_path = (os.getenv("TEXT2SQL_SCHEMA_PATH") or "").strip()
|
||||||
# This file is in backend/app/services/text2sql.py
|
candidate_paths = []
|
||||||
base_dir = cls._project_root()
|
if env_path:
|
||||||
doc_path = os.path.join(base_dir, 'docs', '(表+字段).md')
|
candidate_paths.append(env_path)
|
||||||
with open(doc_path, 'r', encoding='utf-8') as f:
|
|
||||||
cls._schema_text = f.read()
|
candidate_paths.extend([
|
||||||
except Exception as e:
|
os.path.join(cls._backend_dir(), 'docs', schema_filename),
|
||||||
cls._schema_text = f"Failed to load schema: {e}"
|
os.path.join(cls._project_root(), 'docs', schema_filename),
|
||||||
|
os.path.join(os.getcwd(), 'docs', schema_filename),
|
||||||
|
])
|
||||||
|
|
||||||
|
unique_paths = []
|
||||||
|
seen = set()
|
||||||
|
for path in candidate_paths:
|
||||||
|
normalized = os.path.normpath(path)
|
||||||
|
if normalized not in seen:
|
||||||
|
seen.add(normalized)
|
||||||
|
unique_paths.append(path)
|
||||||
|
|
||||||
|
for doc_path in unique_paths:
|
||||||
|
try:
|
||||||
|
if not os.path.exists(doc_path):
|
||||||
|
continue
|
||||||
|
with open(doc_path, 'r', encoding='utf-8') as f:
|
||||||
|
cls._schema_text = f.read()
|
||||||
|
cls._log("info", f"Loaded Text2SQL schema from {doc_path}")
|
||||||
|
break
|
||||||
|
except Exception as exc:
|
||||||
|
cls._log("warning", f"Failed to load Text2SQL schema from {doc_path}: {exc}")
|
||||||
|
|
||||||
|
if cls._schema_text is None:
|
||||||
|
tried = ", ".join(unique_paths)
|
||||||
|
cls._schema_text = f"Failed to load schema: schema file not found. Tried: {tried}"
|
||||||
|
cls._log("warning", cls._schema_text)
|
||||||
return cls._schema_text
|
return cls._schema_text
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
services:
|
services:
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# hxops-backend: Flask 后端服务 (端口: 5000)
|
# hxops-backend: Flask 后端服务 (端口: 5000)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
hxops-backend:
|
hxops-backend:
|
||||||
image: ${BACKEND_IMAGE:-hxops-backend:local}
|
image: ${BACKEND_IMAGE:-hxops-backend:local}
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: backend/Dockerfile
|
||||||
container_name: hxops-backend
|
container_name: hxops-backend
|
||||||
restart: always
|
restart: always
|
||||||
# 与 scripts/deploy_compose.sh 使用的 .env.<ENV_NAME> 对齐(通过 COMPOSE_ENV_BASENAME)
|
# 与 scripts/deploy_compose.sh 使用的 .env.<ENV_NAME> 对齐(通过 COMPOSE_ENV_BASENAME)
|
||||||
|
|||||||
Reference in new issue
Block a user