b09f90bfcc
CI / lint-and-test (pull_request) Failing after 9s
Prevent worker/web clobbering of meta variants via flock and merge-by-id, make filter timeouts thread-local, harden job-id/stem sanitization, migrate TemplateResponse API, and remove the compare-bg experiment. Co-authored-by: Cursor <cursoragent@cursor.com>
3.0 KiB
3.0 KiB
Cleanup Plan — live.f12.rocks
Phase 0 analysis (2026-07-18). Working branch: cleanup/code-quality.
Project snapshot
| Area | Detail |
|---|---|
| Stack | Python 3.11 (Docker), FastAPI, gmic, rembg, Docker Compose |
| Size | ~7 Python modules under app/, ~1.3k LOC |
| Tests | None (pre-cleanup) |
| Lint/format | None (pre-cleanup) |
| CI | None |
| Lockfile | Soft pins in requirements.txt only |
Findings (prioritized)
- No test/CI/lint baseline — high risk for refactors
pipeline.pygod module (642 LOC) — medium risk; defer split until tests exist- Meta JSON race (worker + web concurrent writes) — documented, not fixed (behavior change)
- Dead code:
blend_layers()unused - Duplication: atomic JSON write ×3,
basicConfig×2, bool-env parsing ×2, compose env block ×2 - Double meta read on index page (
read_status+read_manifest) — removed (was a standalone experiment)compare-bg/make_random.py— external reference only, document in ARCHITECTURE
Risk matrix
| Area | Risk | Action |
|---|---|---|
| Formatter/linter setup | Low | Phase 1 |
| Dead code removal | Low | Phase 1 |
.gitignore / .python-version |
Low | Phase 1 |
Extract io_utils, env_utils |
Low | Phase 2 |
| Compose env DRY (YAML anchor) | Low | Phase 2 |
Meta read dedup in main.py |
Low | Phase 3 |
| Magic numbers → config constants | Low | Phase 3 |
| Characterization tests | Low | Phase 5 (before deeper refactors) |
pipeline.py split |
Medium | Deferred — tests first, split later |
| Meta file locking | Medium–High | Deferred — behavior change |
| Dependency major bumps | Medium | List only, no auto-bump |
Roadmap & commits
| Phase | Step | Commit theme |
|---|---|---|
| 0 | This file | docs: add cleanup plan from phase-0 analysis |
| 1 | pyproject.toml + ruff | chore: add pyproject.toml with ruff and pytest config |
| 1 | ruff format | style: apply ruff format to Python sources |
| 1 | dead code + gitignore | chore: remove dead code and extend gitignore |
| 2 | io_utils extraction | refactor: extract atomic JSON helpers to io_utils |
| 2 | env_utils + logging | refactor: share env-bool parsing and logging setup |
| 2 | compose DRY | chore: deduplicate compose environment blocks |
| 3 | config constants | refactor: replace magic numbers with named constants |
| 3 | meta read dedup | refactor: read job meta once in list_jobs |
| 4 | dev requirements | chore: add dev requirements and python version pin |
| 4 | Gitea CI | ci: add lint and test workflow |
| 5 | tests | test: add characterization tests for core modules |
| 5 | docs | docs: update README and add ARCHITECTURE |
Conscious non-goals
- No
pipeline.pymodule split in this pass - No meta file locking / concurrency fix
- No dependency major version bumps
No changes to(later removed entirely)compare-bg/experiment- No deploy CI (manual
docker composeon boka stays) - No behavior changes to gmic/rembg processing logic