Spaces:
Paused
Paused
|
Download .agents/skills/debug-python-opticparse/SKILL.md from paras9909/opticparse-python: direct link, hf CLI and curl.
- Browser
- Download file 2.77 kB
-
https://huggingface.co/spaces/paras9909/opticparse-python/resolve/main/.agents/skills/debug-python-opticparse/SKILL.md
- Command line
-
hf download hf://spaces/paras9909/opticparse-python/.agents/skills/debug-python-opticparse/SKILL.md
-
curl -L -o SKILL.md https://huggingface.co/spaces/paras9909/opticparse-python/resolve/main/.agents/skills/debug-python-opticparse/SKILL.md
2.77 kB
metadata
name: debug-python-opticparse
description: >
Enforces Python/FastAPI idioms, PEP8 standards, and mandatory local pytest
execution for all changes to the OpticParse Python backend (server.py and
related files in the repository root).
OpticParse β Python / FastAPI Debugging Skill
Scope
This skill applies to ALL files in the repository root that belong to the OpticParse Python service:
server.pyβ Main FastAPI applicationtest_server.pyβ Pytest unit testsrequirements.txtβ Python dependenciesDockerfileβ Docker build for Render deployment.envβ Environment variables (never commit this)render.yamlβ Lines 1β19 only (Python service block)
DO NOT modify any files inside opticparse-js/. That directory belongs to
the PhishVision TypeScript service and is managed by a separate skill.
Coding Standards
Style
- Follow PEP 8 strictly: 4-space indentation, snake_case for functions and variables, PascalCase for classes.
- Add type hints to all public function signatures.
- Maximum line length: 100 characters.
- Use f-strings for string formatting, not
.format()or%.
FastAPI Patterns
- Use
Depends()for dependency injection (e.g., API key validation). - Raise
HTTPExceptionfor all error responses β never return raw dicts with error codes. - Define request/response models using Pydantic
BaseModel. - All new endpoints must include OpenAPI docstrings.
AI Provider Rotation
- New AI providers must follow the existing
AI_PROVIDERSlist structure:{ "name": "ProviderName", "key": os.getenv("ENV_VAR_NAME"), "base": "https://api.provider.com/v1", "model": "model-name", "vision": True, # or False for text-only fallback } - Always add new providers to the END of the list (lowest priority).
Logging
- Use the existing
loggerinstance (logging.getLogger("vision-scrape")). - Never use
print()for operational logging. - Log at
INFOfor successful operations,WARNINGfor retries,ERRORfor failures.
Playwright / Browser
- Always close browser instances in a
finallyblock to prevent memory leaks on Render's 512MB free tier. - Abort unnecessary resource types (media, font, websocket) via request interception to save bandwidth.
Pre-Commit Verification
Before committing any changes, you MUST run:
python -m pytest test_server.py -v
If any test fails, fix the issue before committing. Do not skip or ignore failing tests.
Post-Deploy Verification
After pushing changes, verify the live deployment:
curl -s https://opticparse-python-sg.onrender.com/health
Expected response: {"status":"ok","service":"opticparse","version":"1.0.0"}