-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
302 lines (230 loc) · 10.1 KB
/
justfile
File metadata and controls
302 lines (230 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# Git Metadata Extractor - Task Runner
# Usage: just <command>
# Default host and port (can be overridden with HOST=value PORT=value just serve)
HOST := env_var_or_default("HOST", "0.0.0.0")
PORT := env_var_or_default("PORT", "1234")
WORKERS := env_var_or_default("WORKERS", "4")
# Default recipe - show available commands
default:
@just --list
# ============================================================================
# Installation & Setup
# ============================================================================
# Install dependencies from pyproject.toml
install:
uv pip install .
# Install in development mode with all dependencies
install-dev:
uv pip install -e ".[dev]"
# Set up development environment (install + create .env if needed)
setup:
@echo "Setting up Git Metadata Extractor development environment..."
pip install -e .
@if [ ! -f .env ]; then echo "Creating .env file from template..."; echo "OPENAI_API_KEY=\nOPENROUTER_API_KEY=\nGITHUB_TOKEN=\nGITLAB_TOKEN=\nMODEL=gpt-4\nPROVIDER=openai\nCACHE_ENABLED=true" > .env; echo ".env file created. Please edit with your API keys."; else echo ".env file already exists."; fi
@echo "Setup complete!"
# ============================================================================
# Running the API Server
# ============================================================================
# Serve the FastAPI app in production mode
serve:
uvicorn src.api:app --host {{HOST}} --port {{PORT}} --workers {{WORKERS}}
# Serve the FastAPI app in development mode with auto-reload
serve-dev:
uvicorn src.api:app --host {{HOST}} --port {{PORT}} --reload
# Serve in development mode with debug logging
serve-dev-debug:
LOG_LEVEL=DEBUG uvicorn src.api:app --host {{HOST}} --port {{PORT}} --reload --log-level debug
# Serve with single worker (useful for debugging)
serve-single:
uvicorn src.api:app --host {{HOST}} --port {{PORT}} --workers 1
# Serve using gunicorn (production-ready)
serve-gunicorn:
gunicorn src.api:app --workers {{WORKERS}} --worker-class uvicorn.workers.UvicornWorker --bind {{HOST}}:{{PORT}}
# ============================================================================
# CLI Commands
# ============================================================================
# Run the CLI tool to extract metadata from a repository
extract URL OUTPUT="output_file.json":
python src/main.py --url {{URL}} --output_path {{OUTPUT}}
# Extract metadata from a default test repository
extract-test:
python src/main.py --url https://github.com/qchapp/lungs-segmentation --output_path test_output.json
# ============================================================================
# Docker Commands
# ============================================================================
# Build the Docker image
docker-build:
docker build -t git-metadata-extractor -f tools/image/Dockerfile .
# Run the Docker container in production mode
docker-run:
docker run -it --rm --env-file .env -p {{PORT}}:{{PORT}} --name git-metadata-extractor git-metadata-extractor
# Run the Docker container in development mode with volume mount
docker-dev:
docker run -it --env-file .env -p {{PORT}}:{{PORT}} -v .:/app --entrypoint bash git-metadata-extractor
# Run the Docker container with bash entrypoint
docker-shell:
docker run -it --env-file .env -p {{PORT}}:{{PORT}} -v .:/app --entrypoint bash git-metadata-extractor
# Start Selenium container for ORCID functionality
docker-selenium:
docker run --rm -d -p 4444:4444 -p 7900:7900 --shm-size="2g" --name selenium-standalone-firefox selenium/standalone-firefox
# Stop Selenium container
docker-selenium-stop:
docker stop selenium-standalone-firefox
# Build and run Docker container
docker-up: docker-build docker-run
# ============================================================================
# Testing
# ============================================================================
# Run all tests
test:
PYTHONPATH=src pytest tests/ -v
# Run tests with coverage
test-coverage:
PYTHONPATH=src pytest tests/ --cov=src --cov-report=html --cov-report=term
# Run specific test file
test-file FILE:
PYTHONPATH=src pytest {{FILE}} -v
# Run tests in watch mode (requires pytest-watch)
test-watch:
PYTHONPATH=src ptw tests/
# ============================================================================
# Cache Management (via API)
# ============================================================================
# Get cache statistics
cache-stats:
curl -X GET http://localhost:{{PORT}}/v1/cache/stats | python -m json.tool
# Clean up expired cache entries
cache-cleanup:
curl -X POST http://localhost:{{PORT}}/v1/cache/cleanup | python -m json.tool
# Clear all cache entries
cache-clear:
curl -X POST http://localhost:{{PORT}}/v1/cache/clear | python -m json.tool
# Enable caching
cache-enable:
curl -X POST http://localhost:{{PORT}}/v1/cache/enable | python -m json.tool
# Disable caching
cache-disable:
curl -X POST http://localhost:{{PORT}}/v1/cache/disable | python -m json.tool
# ============================================================================
# Development Utilities
# ============================================================================
# Format code using black
format:
black src/
# Format code using ruff
format-ruff:
ruff format src/
# Lint code using ruff
lint:
ruff check src/
# Lint and fix issues automatically
lint-fix:
ruff check --fix src/
# Type check using mypy
type-check:
mypy src/
# Run all code quality checks
check: lint type-check
@echo "All checks passed!"
# ============================================================================
# API Testing & Documentation
# ============================================================================
# Open the interactive API documentation (Swagger UI)
docs:
@echo "Opening API documentation at http://localhost:{{PORT}}/docs"
@if command -v xdg-open > /dev/null; then xdg-open http://localhost:{{PORT}}/docs; elif command -v open > /dev/null; then open http://localhost:{{PORT}}/docs; else echo "Please open http://localhost:{{PORT}}/docs in your browser"; fi
# ============================================================================
# Project Documentation Site (MkDocs + Mike)
# ============================================================================
# Serve project documentation locally with live reload
docs-serve:
mkdocs serve
# Build project documentation and fail on warnings
docs-build:
mkdocs build --strict
# List published documentation versions and aliases
docs-version-list:
mike list
# Deploy docs from current branch as dev + latest aliases
docs-deploy-dev:
mike deploy --push --branch gh-pages --update-aliases dev latest
# Deploy docs for a specific release version and update stable alias
docs-deploy-release VERSION:
mike deploy --push --branch gh-pages --update-aliases {{VERSION}} stable
# Set the default docs version/alias
docs-set-default VERSION:
mike set-default --push --branch gh-pages {{VERSION}}
# Test the main extract endpoint
api-test-extract:
curl -X GET "http://localhost:{{PORT}}/v1/extract/json/https://github.com/qchapp/lungs-segmentation" | python -m json.tool
# Test the extract endpoint with force refresh
api-test-extract-refresh:
curl -X GET "http://localhost:{{PORT}}/v1/extract/json/https://github.com/qchapp/lungs-segmentation?force_refresh=true" | python -m json.tool
# Test the GIMIE endpoint
api-test-gimie:
curl -X GET "http://localhost:{{PORT}}/v1/repository/gimie/json-ld/https://github.com/qchapp/lungs-segmentation" | python -m json.tool
# ============================================================================
# Cleanup
# ============================================================================
# Clean up Python cache files
clean-py:
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type f -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
# Clean up test artifacts
clean-test:
rm -rf .pytest_cache htmlcov .coverage
# Clean up all cache and temporary files
clean-all: clean-py clean-test
rm -f api_cache.db test_output.json
@echo "Cleaned up all cache and temporary files"
# ============================================================================
# Project Information
# ============================================================================
# Show project version
version:
@python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])"
# Show environment info
env-info:
@echo "Python version:"
@python --version
@echo "\nPip version:"
@pip --version
@echo "\nInstalled packages:"
@pip list | grep -E "(fastapi|uvicorn|gimie|pydantic|openai|google-genai)"
# Show project dependencies
deps:
@python -c "import tomllib; deps = tomllib.load(open('pyproject.toml', 'rb'))['project']['dependencies']; print('\n'.join(deps))"
# ============================================================================
# Combined Workflows
# ============================================================================
# Complete development setup and start server
dev: setup serve-dev
# # Run checks and tests before committing
# pre-commit: lint test
# @echo "✓ All pre-commit checks passed!"
# Full CI pipeline (lint, type-check, test)
ci: lint type-check test-coverage
@echo "✓ CI pipeline completed successfully!"
# ============================================================================
# Pre-commit Commands
# ============================================================================
# Install pre-commit hooks
pre-commit-install:
pre-commit install
# Install pre-commit hooks for commit-msg
pre-commit-install-msg:
pre-commit install --hook-type commit-msg
# Run pre-commit on all files
pre-commit:
pre-commit run --all-files
# Run pre-commit on staged files only
pre-commit-staged:
pre-commit run
# Update pre-commit hooks to latest versions
pre-commit-update:
pre-commit autoupdate
# Clean pre-commit cache
pre-commit-clean:
pre-commit clean