Files
watermarks-remover/Makefile
T
Guillaume Meyer (The Opinionated Man)andGitHub 723627716c chore: add Ruff linting and formatting with CI enforcement (#103)
Introduce Ruff (pinned at 0.16.3) as the project linter + formatter and
enforce it in CI:

- requirements-dev.txt: pin ruff==0.16.3 (exact pins, no drift)
- ruff.toml: line-length 100, target py312; rule set E/F/W/I/UP/B/SIM/RUF/PLW/S
  with deliberate ignores (E501 for content strings, S603 for safe_arg
  subprocess calls, S101 asserts in tests) and per-file test ignores
- Makefile: add lint / format / lint-fix targets
- .github/workflows/ci.yml: add lint job (ruff check + format --check)
- .gitignore: whitelist ruff.toml

Also fix every finding the new gate surfaced so CI is green:
- 109+ auto-fixes from ruff --fix (import sorting, simplifications,
  unused vars, re.I aliases, etc.)
- explicit check=False on all subprocess.run calls (PLW1510)
- harden sitemap XML parsing: reject DTD/entity declarations (S314)
- replace hardcoded /tmp paths in tests with tmp_path (S108)
- narrow/annotate intentional bare excepts (S110/S112), bind loop vars
  in closures (B023), raise ... from None (B904), strict= for zip (B905)
- ruff format applied across service/ and tests/

Verified: ruff check + ruff format --check pass; 287 tests pass, 1 skip.
2026-08-16 17:32:40 -07:00

128 lines
4.2 KiB
Makefile

.PHONY: test lint format lint-fix smoke smoke-synthid bootstrap-synthid docker-synthid-build docker-synthid-help \
smoke-ctrlregen bootstrap-ctrlregen docker-ctrlregen-build docker-ctrlregen-help \
smoke-markllm bootstrap-markllm docker-markllm-build docker-markllm-help \
smoke-markdiffusion bootstrap-markdiffusion docker-markdiffusion-build docker-markdiffusion-help \
docker-core-build docker-core-help serve compose-up compose-up-heavy compose-check \
install-skill install-cursor-text-skill clean
SCRIPTS := service/scripts
PYTHON ?= $(shell if [ -x .venv/bin/python ]; then echo .venv/bin/python; else echo python3; fi)
test:
$(PYTHON) -m pytest
lint:
$(PYTHON) -m ruff check service tests
format:
$(PYTHON) -m ruff format --check service tests
lint-fix:
$(PYTHON) -m ruff check --fix service tests
smoke:
-python3 $(SCRIPTS)/inspect_text.py tests/fixtures/sample_watermarked.txt
python3 $(SCRIPTS)/clean_text.py tests/fixtures/sample_watermarked.txt -o /tmp/wm.cleaned.txt --stats
python3 $(SCRIPTS)/rewrite_text.py tests/fixtures/sample_watermarked.txt --backend print-prompt >/dev/null
-python3 $(SCRIPTS)/inspect_file.py tests/fixtures/sample_ai.md
python3 $(SCRIPTS)/clean_file.py tests/fixtures/sample_ai.md -o /tmp/sample_ai.cleaned.md
python3 $(SCRIPTS)/clean_file.py tests/fixtures/sample_ai.html -o /tmp/sample_ai.cleaned.html
python3 $(SCRIPTS)/clean_file.py tests/fixtures/sample_meta.svg -o /tmp/sample_meta.cleaned.svg
@echo "smoke ok"
smoke-synthid:
@if [ -z "$(REVERSE_SYNTHID_DIR)" ]; then \
echo "smoke-synthid skipped (set REVERSE_SYNTHID_DIR)"; \
else \
$(PYTHON) $(SCRIPTS)/score_synthid.py --help >/dev/null && echo "score_synthid adapter present"; \
fi
bootstrap-synthid:
./service/scripts/setup_synthid.sh
docker-synthid-build:
docker build -f service/Dockerfile.synthid -t watermarks-remover-synthid-scorer service/
docker-synthid-help:
docker run --rm watermarks-remover-synthid-scorer --help
smoke-ctrlregen:
@if [ -z "$(NOAI_WATERMARK_DIR)" ]; then \
echo "smoke-ctrlregen skipped (set NOAI_WATERMARK_DIR)"; \
else \
$(PYTHON) $(SCRIPTS)/clean_ctrlregen.py --help >/dev/null && echo "clean_ctrlregen adapter present"; \
fi
bootstrap-ctrlregen:
./service/scripts/setup_ctrlregen.sh
docker-ctrlregen-build:
docker build -f service/Dockerfile.ctrlregen -t watermarks-remover-ctrlregen service/
docker-ctrlregen-help:
docker run --rm watermarks-remover-ctrlregen --help
smoke-markllm:
@if [ -z "$(MARKLLM_DIR)" ]; then \
echo "smoke-markllm skipped (set MARKLLM_DIR)"; \
else \
$(PYTHON) $(SCRIPTS)/detect_text_watermark.py --help >/dev/null && echo "detect_text_watermark adapter present"; \
fi
bootstrap-markllm:
./service/scripts/setup_markllm.sh
docker-markllm-build:
docker build -f service/Dockerfile.markllm -t watermarks-remover-markllm service/
docker-markllm-help:
docker run --rm watermarks-remover-markllm --help
smoke-markdiffusion:
@if [ -z "$(MARKDIFFUSION_DIR)" ]; then \
echo "smoke-markdiffusion skipped (set MARKDIFFUSION_DIR)"; \
else \
$(PYTHON) $(SCRIPTS)/markdiffusion_harness.py --help >/dev/null && echo "markdiffusion_harness adapter present"; \
fi
bootstrap-markdiffusion:
./service/scripts/setup_markdiffusion.sh
docker-markdiffusion-build:
docker build -f service/Dockerfile.markdiffusion -t watermarks-remover-markdiffusion service/
docker-markdiffusion-help:
docker run --rm watermarks-remover-markdiffusion --help
# Core HTTP service (text + file/image metadata cleaning).
docker-core-build:
docker build -f service/Dockerfile -t watermarks-remover service/
docker-core-help:
docker run --rm watermarks-remover /app/scripts/server.py --help
# Run the HTTP service locally (stdlib only, no Docker).
serve:
$(PYTHON) $(SCRIPTS)/server.py --host 127.0.0.1 --port 8765
compose-up:
docker compose up --build -d
compose-up-heavy:
docker compose --profile harness --profile heavy up --build -d
compose-check:
./compose-check.sh
install-skill:
mkdir -p $(HOME)/.grok/skills
ln -sfn $(CURDIR)/skills/remove-ai-marks $(HOME)/.grok/skills/remove-ai-marks
@echo "linked -> $(HOME)/.grok/skills/remove-ai-marks"
install-cursor-text-skill:
$(PYTHON) install_skill.py
clean:
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
rm -rf .pytest_cache .venv