Skip to content

Commit 2f000d0

Browse files
committed
chore(Makefile): add pre-commit installation to setup and dev commands for better code quality management
fix(main.py): reorder imports for consistency and improved readability feat(services.py): load environment variables from .env file to manage sensitive data securely chore(pyproject.toml): add configuration for uv tool and ensure proper build backend setup
1 parent a90ac53 commit 2f000d0

File tree

5 files changed

+175
-36
lines changed

5 files changed

+175
-36
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
.PHONY: setup dev test lint up down
22

3+
# Install all dependencies including dev-groups
34
setup:
45
uv sync
6+
uv run pre-commit install
57

8+
# Run the local development server with auto-reload
69
dev:
710
uv sync
11+
uv run pre-commit install
812
uv run uvicorn app.main:app --reload --port 8000
913

14+
# Run all tests using pytest
1015
test:
1116
uv run pytest
1217

18+
# Fix linting and format code using ruff
1319
lint:
1420
uv run ruff check . --fix
1521
uv run ruff format .
1622

23+
# Build and start the containerized service
1724
up:
1825
docker compose up --build
1926

27+
# Stop and remove containers
2028
down:
2129
docker compose down

app/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from fastapi import FastAPI, HTTPException
2-
from app.models import ParseRequest, OrderExtraction
2+
from app.models import OrderExtraction, ParseRequest
33
from app.services import parse_order_from_text
44

5+
56
app = FastAPI(
67
title="Structured Data Extractor API",
78
description="AI-powered engine to transform unstructured text into validated order schemas.",

app/services.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
from openai import OpenAI
44
from app.models import OrderExtraction
55

6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
9+
610
client = instructor.from_openai(OpenAI(api_key=os.getenv("OPENAI_API_KEY")))
711

812

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ dev = [
2020
"pre-commit>=3.6.0",
2121
]
2222

23+
[tool.uv]
24+
package = false
25+
2326
[tool.ruff]
2427
line-length = 88
2528
target-version = "py310"
2629

2730
[build-system]
2831
requires = ["hatchling"]
29-
build-backend = "hatchling.build"
32+
build-backend = "hatchling.build"

0 commit comments

Comments
 (0)