Skip to content

Commit 58a3b9c

Browse files
Merge branch 'feature/sql-tokenizer' into pre-release
2 parents 9b91355 + 6a962ac commit 58a3b9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7669
-46
lines changed

src/FrontEnd/.env.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Server Configuration
2+
PORT=8000
3+
HOST=0.0.0.0
4+
5+
# Logging Configuration
6+
# Options: prod, info, debug
7+
LOGGING_MODE=info
8+
9+
# Testing Configuration
10+
TEST_SERVER_URL=http://localhost:8000
11+
12+
# Backend Execution Engine (gRPC)
13+
BACKEND_HOST=localhost
14+
BACKEND_PORT=7000
15+
16+
# Redis Cache
17+
REDIS_HOST=localhost
18+
REDIS_PORT=6379
19+
20+
# S3/DigitalOcean Spaces
21+
S3_ACCESS_KEY=your-access-key
22+
S3_SECRET_KEY=your-secret-key
23+
S3_ENDPOINT_URL=https://atl1.digitaloceanspaces.com
24+
S3_BUCKET_NAME=your-bucket-name
25+
S3_REGION=us-east-1

src/FrontEnd/Dockerfile

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1-
FROM python:3.11-slim
1+
FROM python:3.10-slim
22

33
WORKDIR /app
44

5-
# Install dependencies
6-
COPY requirements.txt .
5+
# Install system dependencies for gRPC and C++ runtime
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
curl \
8+
libc++1 \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Install Python dependencies
12+
COPY FrontEnd/requirements.txt .
713
RUN pip install --no-cache-dir -r requirements.txt
814

15+
# Copy proto files and generate gRPC code
16+
COPY Contract /contract
17+
RUN mkdir -p app/grpc_gen && \
18+
python -m grpc_tools.protoc \
19+
-I/contract \
20+
--python_out=app/grpc_gen \
21+
--grpc_python_out=app/grpc_gen \
22+
/contract/operation.proto && \
23+
sed -i 's/import operation_pb2/from app.grpc_gen import operation_pb2/' app/grpc_gen/operation_pb2_grpc.py && \
24+
touch app/grpc_gen/__init__.py
25+
926
# Copy application code
10-
COPY . .
11-
COPY ../../.env
27+
COPY FrontEnd/app ./app
28+
29+
# Copy pre-built C++ parser module
30+
COPY FrontEnd/cpp_lib/output/optisql_parser.cpython-310-x86_64-linux-gnu.so ./cpp_lib/output/
1231

13-
# Expose port (will be read from config.yml)
32+
# Expose port
1433
EXPOSE 8000
1534

16-
# Run the application
17-
CMD ["python", "-m", "app.main"]
35+
# Run the application with uvicorn
36+
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

src/FrontEnd/Makefile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.PHONY: help setup test grpc-gen cpp-parser clean run
2+
3+
PROTO_DIR := ../Contract
4+
GRPC_OUT := app/grpc_gen
5+
CPP_LIB := cpp_lib
6+
CONDA_ENV := optisql
7+
8+
help:
9+
@echo "Available targets:"
10+
@echo " make setup - Setup conda environment and install dependencies"
11+
@echo " make test - Run Python tests"
12+
@echo " make grpc-gen - Generate gRPC Python code from proto files"
13+
@echo " make cpp-parser - Build the C++ parser Python module"
14+
@echo " make clean - Clean generated files"
15+
@echo " make run - Run the FastAPI server"
16+
@echo " make all - Setup, build C++ parser, generate gRPC, and run tests"
17+
18+
setup:
19+
@echo "Setting up conda environment..."
20+
@conda create -n $(CONDA_ENV) python=3.10 -y || true
21+
@echo "Installing dependencies..."
22+
conda run -n $(CONDA_ENV) pip install --upgrade pip
23+
conda run -n $(CONDA_ENV) pip install -r requirements.txt
24+
@echo "Setup complete! Activate with: conda activate $(CONDA_ENV)"
25+
26+
test:
27+
@echo "Running Python tests..."
28+
conda run -n $(CONDA_ENV) pytest -v
29+
30+
grpc-gen:
31+
@echo "Generating gRPC Python code..."
32+
@mkdir -p $(GRPC_OUT)
33+
conda run -n $(CONDA_ENV) python -m grpc_tools.protoc \
34+
-I$(PROTO_DIR) \
35+
--python_out=$(GRPC_OUT) \
36+
--grpc_python_out=$(GRPC_OUT) \
37+
$(PROTO_DIR)/operation.proto
38+
@echo "Fixing imports in generated files..."
39+
@sed -i 's/import operation_pb2/from app.grpc_gen import operation_pb2/' $(GRPC_OUT)/operation_pb2_grpc.py 2>/dev/null || \
40+
sed -i '' 's/import operation_pb2/from app.grpc_gen import operation_pb2/' $(GRPC_OUT)/operation_pb2_grpc.py
41+
@echo "gRPC code generated in $(GRPC_OUT)"
42+
43+
cpp-parser:
44+
@echo "Building C++ parser Python module..."
45+
$(MAKE) -C $(CPP_LIB) python
46+
47+
cpp-test:
48+
@echo "Running C++ parser tests..."
49+
$(MAKE) -C $(CPP_LIB) test
50+
51+
clean:
52+
@echo "Cleaning generated files..."
53+
rm -f $(GRPC_OUT)/operation_pb2.py $(GRPC_OUT)/operation_pb2_grpc.py
54+
$(MAKE) -C $(CPP_LIB) clean
55+
@echo "Clean complete!"
56+
57+
run:
58+
@echo "Starting FastAPI server..."
59+
conda run -n $(CONDA_ENV) uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
60+
61+
all: setup cpp-parser grpc-gen test
62+
@echo "All setup complete!"

0 commit comments

Comments
 (0)