Skip to content

Commit 6931fa5

Browse files
committed
Merge branch 'master' into feature/105-add-setup-clickhouse-promptdir
2 parents 0c4622b + 717bfb1 commit 6931fa5

27 files changed

+1360
-418
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
###############################################
44

55
# LLM_PROVIDER=openai
6-
# OPEN_AI_LLM_KEY=
7-
# OPEN_AI_LLM_MODEL=gpt-4o
6+
# OPEN_AI_KEY=
7+
# OPEN_MODEL_PREF=gpt-4o
88

99
# LLM_PROVIDER=gemini
1010
# GEMINI_API_KEY=

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ test_lhm/
1010
.cursorignore
1111
.vscode
1212
table_info_db
13-
ko_reranker_local
13+
ko_reranker_local

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Python 3.10 slim 이미지 기반
2+
FROM python:3.12-slim
3+
4+
# 시스템 라이브러리 설치
5+
RUN apt-get update && apt-get install -y \
6+
build-essential \
7+
curl \
8+
software-properties-common \
9+
git \
10+
libpq-dev \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# 작업 디렉토리 설정
14+
WORKDIR /app
15+
16+
# 의존성 파일 복사 및 설치
17+
COPY requirements.txt .
18+
RUN pip install --no-cache-dir -r requirements.txt
19+
20+
# 전체 서비스 코드 복사
21+
COPY . .
22+
23+
# Python 환경 설정
24+
ENV PYTHONPATH=/app
25+
ENV PYTHONUNBUFFERED=1
26+
27+
# Streamlit 포트 노출
28+
EXPOSE 8501
29+
30+
# Streamlit 실행 명령
31+
CMD ["python", "-c", "from llm_utils.tools import set_gms_server; import os; set_gms_server(os.getenv('DATAHUB_SERVER', 'http://localhost:8080'))"]
32+
CMD ["streamlit", "run", "./interface/streamlit_app.py", "--server.port=8501"]

README.md

Lines changed: 201 additions & 139 deletions
Large diffs are not rendered by default.

cli/__init__.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
"""
2-
Datahub GMS 서버 URL을 설정하고, 필요 시 Streamlit 인터페이스를 실행하는 CLI 프로그램입니다.
2+
Lang2SQL CLI 프로그램입니다.
3+
이 프로그램은 Datahub GMS 서버 URL을 설정하고, 필요 시 Streamlit 인터페이스를 실행합니다.
4+
5+
명령어 예시: lang2sql --datahub_server http://localhost:8080 --run-streamlit
36
"""
47

8+
import logging
59
import subprocess
610

711
import click
812

13+
from llm_utils.check_server import CheckServer
914
from llm_utils.tools import set_gms_server
15+
from version import __version__
16+
17+
logging.basicConfig(
18+
level=logging.INFO,
19+
format="%(asctime)s [%(levelname)s] %(message)s",
20+
datefmt="%Y-%m-%d %H:%M:%S",
21+
)
22+
logger = logging.getLogger(__name__)
1023

1124

1225
@click.group()
13-
@click.version_option(version="0.1.4")
26+
@click.version_option(version=__version__)
1427
@click.pass_context
1528
@click.option(
1629
"--datahub_server",
@@ -64,11 +77,20 @@ def cli(
6477
'set_gms_server' 함수에서 ValueError가 발생할 경우, 프로그램은 비정상 종료(exit code 1)합니다.
6578
"""
6679

67-
try:
80+
logger.info(
81+
"Initialization started: GMS server = %s, run_streamlit = %s, port = %d",
82+
datahub_server,
83+
run_streamlit,
84+
port,
85+
)
86+
87+
if CheckServer.is_gms_server_healthy(url=datahub_server):
6888
set_gms_server(datahub_server)
69-
except ValueError as e:
70-
click.secho(f"GMS 서버 URL 설정 실패: {str(e)}", fg="red")
89+
logger.info("GMS server URL successfully set: %s", datahub_server)
90+
else:
91+
logger.error("GMS server health check failed. URL: %s", datahub_server)
7192
ctx.exit(1)
93+
7294
if run_streamlit:
7395
run_streamlit_command(port)
7496

@@ -89,6 +111,8 @@ def run_streamlit_command(port: int) -> None:
89111
- subprocess 호출 실패 시 예외가 발생할 수 있습니다.
90112
"""
91113

114+
logger.info("Starting Streamlit application on port %d...", port)
115+
92116
try:
93117
subprocess.run(
94118
[
@@ -100,8 +124,9 @@ def run_streamlit_command(port: int) -> None:
100124
],
101125
check=True,
102126
)
127+
logger.info("Streamlit application started successfully.")
103128
except subprocess.CalledProcessError as e:
104-
click.echo(f"Streamlit 실행 실패: {e}")
129+
logger.error("Failed to start Streamlit application: %s", e)
105130
raise
106131

107132

@@ -132,4 +157,5 @@ def run_streamlit_cli_command(port: int) -> None:
132157
- Streamlit 실행에 실패할 경우 subprocess 호출에서 예외가 발생할 수 있습니다.
133158
"""
134159

160+
logger.info("Executing 'run-streamlit' command on port %d...", port)
135161
run_streamlit_command(port)

data_utils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# data_utils 패키지 초기화 파일

docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
streamlit:
3+
build: .
4+
ports:
5+
- "8501:8501"
6+
volumes:
7+
- .:/app
8+
env_file:
9+
- .env
10+
environment:
11+
- DATABASE_URL=postgresql://postgres:password@db:5432/streamlit_db
12+
depends_on:
13+
- db
14+
15+
db:
16+
image: pgvector/pgvector:pg17
17+
container_name: pgvector-db
18+
environment:
19+
POSTGRES_USER: postgres
20+
POSTGRES_PASSWORD: password
21+
POSTGRES_DB: streamlit_db
22+
ports:
23+
- "5432:5432"
24+
volumes:
25+
- pgdata:/var/lib/postgresql/data
26+
- ./postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql
27+
volumes:
28+
pgdata:

docs/README.md

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)