Spaces:
Runtime error
Runtime error
elshaddaioheha commited on
Commit ·
ea64cf1
1
Parent(s): fd0f6b9
chore(api): stabilize backend test setup
Browse filesFiles changed (5)
2 unmodified lines345678910111 unmodified line131415162 unmodified lines*.pyc__pycache__/.pytest_cache/.ruff_cache/.mypy_cache/.venv/node_modules/.next/dist/1 unmodified linehtmlcov/.DS_Store*.log2 unmodified lines345678910111213141 unmodified line1617182 unmodified lines*.pyc__pycache__/.pytest_cache/pytest-cache-files-*/.pytest_cache*/.ruff_cache/.mypy_cache/.venv/*.egg-info/node_modules/.next/dist/1 unmodified linehtmlcov/.DS_Store*.log
41 unmodified lines424344454647484950515220 unmodified lines7374757677787921 unmodified lines10110210310410510610710841 unmodified lines- `npm run build:web` passed.- `npm run test:web` passed.- Tailwind/PostCSS is now using `apps/web/postcss.config.js` in CommonJS format.Verification not completed:- Backend dependency installation and `pytest` have not been completed.- Docker Compose build/run has not been completed.## Immediate Continuation Instructions20 unmodified linesnpm run test:web```3. Run backend checks. Prefer Python 3.11 because the Docker image and ML stack target 3.11.```powershellcd services/api21 unmodified lines### Phase 0: Stabilize the Scaffold- Commit the generated `package-lock.json` and current frontend fixes.- Install backend dev dependencies and run `pytest`.- Fix any Python test failures found by backend checks.### Phase 1: Validate Backend Pipeline41 unmodified lines4243444546474849505152535420 unmodified lines7576777879808121 unmodified lines10310410510610710810911041 unmodified lines- `npm run build:web` passed.- `npm run test:web` passed.- Tailwind/PostCSS is now using `apps/web/postcss.config.js` in CommonJS format.- Backend dependency installation completed with `python -m pip install -e ".[dev]"`.- `python -m pytest` passed for backend tests.- FastAPI startup/shutdown now uses a lifespan handler instead of deprecated `on_event` hooks.Verification not completed:- Docker Compose build/run has not been completed because `docker` is not available on PATH in this environment.## Immediate Continuation Instructions20 unmodified linesnpm run test:web```3. Re-run backend checks after backend changes. Prefer Python 3.11 because the Docker image and ML stack target 3.11.```powershellcd services/api21 unmodified lines### Phase 0: Stabilize the Scaffold- Commit the generated `package-lock.json` and current frontend fixes.- Commit the backend packaging/testability fixes.- Install Docker Desktop or make Docker available on PATH for local Compose validation.### Phase 1: Validate Backend Pipeline
10 unmodified lines111213141516171 unmodified line1920212210 unmodified lines&& rm -rf /var/lib/apt/lists/*COPY pyproject.toml ./RUN pip install ".[dev]"COPY alembic.ini ./COPY alembic ./alembic1 unmodified lineCOPY tests ./testsEXPOSE 800010 unmodified lines111213141516171 unmodified line19202110 unmodified lines&& rm -rf /var/lib/apt/lists/*COPY pyproject.toml ./RUN pip install ".[dev,ml]"COPY alembic.ini ./COPY alembic ./alembic1 unmodified lineCOPY tests ./testsEXPOSE 8000
1234516 unmodified lines222324252627283 unmodified lines32333435363738394041424344454647484950from __future__ import annotationsfrom uuid import uuid4from fastapi import Depends, FastAPI, HTTPException, Query, Request, status16 unmodified lines)settings = get_settings()app = FastAPI(title="Cybully Moderation API", version="0.1.0")app.add_middleware(CORSMiddleware,allow_origins=settings.allowed_cors_origins,3 unmodified lines)@app.on_event("startup")async def startup() -> None:if not hasattr(app.state, "broker"):app.state.broker = RabbitMQBroker(settings)@app.on_event("shutdown")async def shutdown() -> None:broker: RabbitMQBroker | None = getattr(app.state, "broker", None)if broker:await broker.close()@app.get("/health")async def health() -> dict[str, str]:return {"status": "ok", "environment": settings.environment}123456716 unmodified lines2425262728293031323334353637383940414243443 unmodified lines484950515253from __future__ import annotationsfrom contextlib import asynccontextmanagerfrom collections.abc import AsyncIteratorfrom uuid import uuid4from fastapi import Depends, FastAPI, HTTPException, Query, Request, status16 unmodified lines)settings = get_settings()@asynccontextmanagerasync def lifespan(app: FastAPI) -> AsyncIterator[None]:if not hasattr(app.state, "broker"):app.state.broker = RabbitMQBroker(settings)try:yieldfinally:broker: RabbitMQBroker | None = getattr(app.state, "broker", None)if broker:await broker.close()app = FastAPI(title="Cybully Moderation API", version="0.1.0", lifespan=lifespan)app.add_middleware(CORSMiddleware,allow_origins=settings.allowed_cors_origins,3 unmodified lines)@app.get("/health")async def health() -> dict[str, str]:return {"status": "ok", "environment": settings.environment}
6 unmodified lines789101112139 unmodified lines23242526272829301 unmodified line323334356 unmodified lines"aio-pika>=9.5,<10","alembic>=1.14,<2","asyncpg>=0.30,<1","detoxify>=0.5.2,<1","fastapi>=0.115,<1","greenlet>=3.1,<4","pydantic>=2.10,<3",9 unmodified lines"pytest>=8.3,<9","pytest-asyncio>=0.25,<1"][tool.pytest.ini_options]asyncio_mode = "auto"testpaths = ["tests"]pythonpath = ["."]1 unmodified line[tool.ruff]line-length = 100target-version = "py311"6 unmodified lines7891011129 unmodified lines22232425262728293031323334353637383940411 unmodified line4344456 unmodified lines"aio-pika>=9.5,<10","alembic>=1.14,<2","asyncpg>=0.30,<1","fastapi>=0.115,<1","greenlet>=3.1,<4","pydantic>=2.10,<3",9 unmodified lines"pytest>=8.3,<9","pytest-asyncio>=0.25,<1"]ml = ["detoxify>=0.5.2,<1"][build-system]requires = ["setuptools>=70", "wheel"]build-backend = "setuptools.build_meta"[tool.setuptools.packages.find]include = ["app*"]exclude = ["alembic*", "tests*"][tool.pytest.ini_options]addopts = "-p no:cacheprovider"asyncio_mode = "auto"testpaths = ["tests"]pythonpath = ["."]1 unmodified line[tool.ruff]line-length = 100target-version = "py311"
.gitignore+3-1
IMPLEMENTATION_ROADMAP.md+7-5
services/api/Dockerfile+1-2
services/api/app/main.py+17-14
services/api/pyproject.toml+12-2