Flask web application providing batch maintenance tools for mdwiki.org, a medical wiki on Wikimedia infrastructure.
This tool runs on Wikimedia Toolforge (Kubernetes) and provides various jobs to maintain and update medical content on MDWiki. Users authenticate via MediaWiki OAuth and can run background jobs that modify wiki pages through the MediaWiki API.
- OAuth Authentication: Secure login using MediaWiki credentials.
- Background Job System: Run long-running maintenance tasks in the background.
- Redirect Fixer: Tool to fix redirects on one or many pages.
- Medical Content Updater: Tools for updating medical information.
- Admin Management: Interface for managing and monitoring jobs.
The application follows a strict layering: Controller → Service → Repository → Database.
- Flask App: Main application framework.
- Background Jobs: Managed using a custom worker system in
src/main_app/jobs/. - MediaWiki Integration: Uses
mwclientandmwoauth. - Database: SQLAlchemy for data persistence (MySQL in production, SQLite for tests).
- Python 3.13+
- MariaDB/MySQL (for local development, you can use SQLite)
-
Clone the repository:
git clone <repository-url> cd mdwiki-org-scripts
-
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate pip install -r requirements.txt pip install -r requirements-dev.txt -
Set up environment variables: Copy
.env.exampleto.envand fill in the required values.cp .env.example .env
python src/app1.pyTests are managed with pytest. Network access is blocked by default in tests.
python -m pytest tests/ -v # All tests
python -m pytest tests/ -v -m unit # Unit tests only
python -m pytest tests/ -v -m integration # Integration tests onlyruff check src/ # Lint
ruff check --fix src/ # Lint with auto-fix
mypy src/ # Type check
black . # Format
isort . # Sort imports
pyright src/ # Type checkLine length is 120 across all tools.
mypy --install-types src
autotyping --none-return --scalar-return src
autotyping --bool-param --int-param src
autotyping --guess-common-names src
autotyping --annotate-magics src
autotyping --annotate-imprecise-magics src
autotyping --safe src
autotyping --aggressive src # aggressiveThe application is deployed on Wikimedia Toolforge using Kubernetes. Deployment details and templates are located in the toolforge_tool/ directory.