11# Structured Output Cookbook - Makefile
22# Provides convenient commands for development and usage
33
4- .PHONY : help install dev test lint format clean docker-build docker-run docker-dev
4+ .PHONY : help install dev test lint format clean docker-build docker-run docker-dev format-check lint-check pre-commit check quality
55
66# Default target
77help : # # Show this help message
@@ -18,7 +18,38 @@ dev: install ## Install development dependencies
1818 @echo " 🛠️ Installing development dependencies..."
1919 uv sync --all-extras
2020
21- # Code Quality
21+ # Code Quality - Core Commands
22+ format : # # Format code with black and ruff
23+ @echo " 💄 Formatting code..."
24+ uv run black src/ tests/
25+ uv run ruff check --fix src/ tests/
26+
27+ format-check : # # Check if code needs formatting
28+ @echo " 🔍 Checking code formatting..."
29+ uv run black --check --diff src/ tests/
30+ uv run ruff check src/ tests/
31+
32+ lint : # # Run all linters
33+ @echo " 🔍 Running linters..."
34+ uv run ruff check src/ tests/
35+ uv run mypy src/ --ignore-missing-imports
36+
37+ lint-fix : # # Fix all linting issues
38+ @echo " 🔧 Fixing linting issues..."
39+ uv run ruff check --fix src/ tests/
40+ uv run black src/ tests/
41+
42+ # Comprehensive Quality Checks
43+ pre-commit : format lint # # Run all pre-commit checks (format + lint)
44+ @echo " ✅ Pre-commit checks completed!"
45+
46+ check : pre-commit test # # Run all quality checks (format, lint, tests)
47+ @echo " ✅ All quality checks passed!"
48+
49+ quality : clean-cache pre-commit test # # Full quality check with cache cleanup
50+ @echo " ✅ Full quality check completed!"
51+
52+ # Tests
2253test : # # Run tests
2354 @echo " 🧪 Running tests..."
2455 uv run pytest
@@ -27,56 +58,45 @@ test-cov: ## Run tests with coverage
2758 @echo " 📊 Running tests with coverage..."
2859 uv run pytest --cov=src/structured_output_cookbook --cov-report=html
2960
30- lint : # # Run linting
31- @echo " 🔍 Running linters..."
32- uv run ruff check .
33- uv run mypy src/
34-
35- lint-fix : # # Fix linting issues
36- @echo " 🔧 Fixing linting issues..."
37- uv run ruff --fix .
38- uv run black .
39-
40- format : # # Format code
41- @echo " 💄 Formatting code..."
42- uv run black .
43- uv run ruff --fix .
61+ test-verbose : # # Run tests with verbose output
62+ @echo " 🧪 Running tests (verbose)..."
63+ uv run pytest -v
4464
45- # CLI Commands
46- list-templates : # # List available predefined templates
65+ # CLI Commands (with quality checks)
66+ list-templates : pre-commit # # List available predefined templates
4767 @echo " 📋 Available templates:"
4868 uv run structured-output list-templates
4969
50- list-schemas : # # List available custom schemas
70+ list-schemas : pre-commit # # List available custom schemas
5171 @echo " 📋 Available schemas:"
5272 uv run structured-output list-schemas
5373
54- example-recipe : # # Run recipe extraction example
74+ example-recipe : pre-commit # # Run recipe extraction example
5575 @echo " 🍝 Running recipe extraction example..."
5676 uv run structured-output extract recipe --input-file examples/recipe.txt --pretty
5777
58- example-job : # # Run job description extraction example
78+ example-job : pre-commit # # Run job description extraction example
5979 @echo " 💼 Running job description extraction example..."
6080 uv run structured-output extract job --input-file examples/job_description.txt --pretty
6181
62- example-news : # # Run news article extraction example
82+ example-news : pre-commit # # Run news article extraction example
6383 @echo " 📰 Running news article extraction example..."
6484 uv run structured-output extract-custom news_article --input-file examples/news_article.txt --pretty
6585
66- example-email : # # Run email extraction example
86+ example-email : pre-commit # # Run email extraction example
6787 @echo " 📧 Running email extraction example..."
6888 uv run structured-output extract email --text " Subject: Meeting Tomorrow\nFrom: john@company.com\nHi team, we have an important meeting tomorrow at 2 PM in conference room A. Please bring your reports." --pretty
6989
70- example-event : # # Run event extraction example
90+ example-event : pre-commit # # Run event extraction example
7191 @echo " 🎉 Running event extraction example..."
7292 uv run structured-output extract event --text " Annual Tech Conference 2024 - Join us on March 15th at San Francisco Convention Center from 9 AM to 6 PM. Registration required." --pretty
7393
74- example-product-review : # # Run product review extraction example
94+ example-product-review : pre-commit # # Run product review extraction example
7595 @echo " ⭐ Running product review extraction example..."
7696 uv run structured-output extract product-review --text " Amazing laptop! The new MacBook Pro is incredible. 5 stars. Great performance, excellent display. Worth every penny. Highly recommended for developers." --pretty
7797
7898# Docker Commands
79- docker-build : # # Build Docker image
99+ docker-build : check # # Build Docker image
80100 @echo " 🐳 Building Docker image..."
81101 docker build -t structured-output-cookbook:latest .
82102
@@ -110,39 +130,42 @@ docker-list-templates: ## List templates with Docker
110130 ./scripts/docker-run.sh list-templates
111131
112132# New CLI Commands
113- validate-schemas : # # Validate all custom YAML schemas
133+ validate-schemas : pre-commit # # Validate all custom YAML schemas
114134 @echo " 🔍 Validating schemas..."
115135 uv run structured-output validate-schemas
116136
117- session-stats : # # Show session statistics
137+ session-stats : pre-commit # # Show session statistics
118138 @echo " 📊 Showing session statistics..."
119139 uv run structured-output session-stats
120140
121- cost-analysis : # # Show cost analysis and recommendations
141+ cost-analysis : pre-commit # # Show cost analysis and recommendations
122142 @echo " 💰 Showing cost analysis..."
123143 uv run structured-output cost-analysis
124144
125145# Batch processing examples
126- batch-example : # # Run batch extraction example
146+ batch-example : pre-commit # # Run batch extraction example
127147 @echo " 🔄 Running batch extraction example..."
128148 mkdir -p examples/batch_input examples/batch_output
129149 echo " Sample recipe 1: Pasta with tomato sauce" > examples/batch_input/recipe1.txt
130150 echo " Sample recipe 2: Chicken curry with rice" > examples/batch_input/recipe2.txt
131151 uv run structured-output batch-extract examples/batch_input/* .txt recipe --output-dir examples/batch_output
132152
133153# Cleanup
134- clean : # # Clean up build artifacts and cache
154+ clean-cache : # # Clean up cache files
155+ @echo " 🧹 Cleaning cache files..."
156+ rm -rf .pytest_cache/
157+ rm -rf .mypy_cache/
158+ rm -rf .ruff_cache/
159+ find . -type d -name __pycache__ -exec rm -rf {} +
160+ find . -type f -name " *.pyc" -delete
161+
162+ clean : clean-cache # # Clean up build artifacts and cache
135163 @echo " 🧹 Cleaning up..."
136164 rm -rf build/
137165 rm -rf dist/
138166 rm -rf * .egg-info/
139- rm -rf .pytest_cache/
140167 rm -rf .coverage
141168 rm -rf htmlcov/
142- rm -rf .mypy_cache/
143- rm -rf .ruff_cache/
144- find . -type d -name __pycache__ -exec rm -rf {} +
145- find . -type f -name " *.pyc" -delete
146169
147170clean-all : clean clean-dist # # Clean everything including distribution files
148171 @echo " 🧹 Deep cleaning complete!"
@@ -177,39 +200,38 @@ check-env: ## Check if required environment variables are set
177200 fi
178201
179202# Release Management
180- bump-version : # # Bump version and create release (usage: make bump-version VERSION=0.1.0)
203+ bump-version : check # # Bump version and create release (usage: make bump-version VERSION=0.1.0)
181204 @if [ -z " $( VERSION) " ]; then \
182205 echo " ❌ Please specify VERSION. Usage: make bump-version VERSION=0.1.0" ; \
183206 exit 1; \
184207 fi
185208 ./scripts/release.sh $(VERSION )
186209
187- build-package : # # Build package for PyPI
210+ build-package : check # # Build package for PyPI
188211 @echo " 📦 Building package..."
189212 uv build
190213 uvx twine check dist/*
191214
192- test-pypi : # # Upload to Test PyPI
215+ test-pypi : check # # Upload to Test PyPI
193216 @echo " 🧪 Uploading to Test PyPI..."
194217 uvx twine upload --repository testpypi dist/*
195218
196- upload-pypi : # # Upload to PyPI (manual backup)
219+ upload-pypi : check # # Upload to PyPI (manual backup)
197220 @echo " 📤 Uploading to PyPI..."
198221 uvx twine upload dist/*
199222
200- check-release : # # Check if package is ready for release
223+ check-release : check # # Check if package is ready for release
201224 @echo " 🔍 Checking release readiness..."
202225 uv build
203226 uvx twine check dist/*
204- uv run pytest
205227 @echo " ✅ Package ready for release!"
206228
207229clean-dist : # # Clean distribution files
208230 @echo " 🧹 Cleaning distribution files..."
209231 rm -rf dist/ build/ * .egg-info/
210232
211233# Release (legacy)
212- build : # # Build the package
234+ build : check # # Build the package
213235 @echo " 📦 Building package..."
214236 uv build
215237
@@ -228,4 +250,15 @@ dev-setup: dev env-example ## Setup development environment
228250 @echo " Don't forget to:"
229251 @echo " 1. Copy .env.example to .env and add your OpenAI API key"
230252 @echo " 2. Run 'make check-env' to verify setup"
231- @echo " 3. Run 'make test' to run tests"
253+ @echo " 3. Run 'make check' to run all quality checks"
254+
255+ # Fix all code issues in one command
256+ fix : # # Fix all formatting and linting issues
257+ @echo " 🔧 Fixing all code issues..."
258+ @echo " Step 1: Formatting with black..."
259+ uv run black src/ tests/
260+ @echo " Step 2: Fixing linting issues with ruff..."
261+ uv run ruff check --fix src/ tests/
262+ @echo " Step 3: Running tests to verify..."
263+ uv run pytest
264+ @echo " ✅ All issues fixed!"
0 commit comments