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 lines345678910111213141 unmodified line161718162 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 lines42434445464748495048495152535420 unmodified lines757677767879808121 unmodified lines10310410510410510610710810911041 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:
- Backend dependency installation and `pytest` have not been completed.- Docker Compose build/run has not been completed.- Docker Compose build/run has not been completed because `docker` is not available on PATH in this environment.
## Immediate Continuation Instructions
20 unmodified linesnpm run test:web```
3. Run backend checks. Prefer Python 3.11 because the Docker image and ML stack target 3.11.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.- Install backend dev dependencies and run `pytest`.- Fix any Python test failures found by backend checks.- 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 lines11121314141516171 unmodified line1920212210 unmodified lines && rm -rf /var/lib/apt/lists/*
COPY pyproject.toml ./RUN pip install ".[dev]"RUN pip install ".[dev,ml]"
COPY alembic.ini ./COPY alembic ./alembic1 unmodified lineCOPY tests ./tests
EXPOSE 8000
123456716 unmodified lines242526272829303132333435363738394025414243443 unmodified lines48495035363738394041424344454647515253from __future__ import annotations
from contextlib import asynccontextmanagerfrom collections.abc import AsyncIteratorfrom uuid import uuid4
from 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: yield finally: broker: RabbitMQBroker | None = getattr(app.state, "broker", None) if broker: await broker.close()
app = FastAPI(title="Cybully Moderation API", version="0.1.0")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.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}6 unmodified lines789101011129 unmodified lines22232425262728293031323334353637383940411 unmodified line434445356 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"]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