Skip to content

Repository files navigation

MDWiki Scripts

Flask web application providing batch maintenance tools for mdwiki.org, a medical wiki on Wikimedia infrastructure.

Project Overview

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.

Features

  • 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.

Architecture

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 mwclient and mwoauth.
  • Database: SQLAlchemy for data persistence (MySQL in production, SQLite for tests).

Getting Started

Prerequisites

  • Python 3.13+
  • MariaDB/MySQL (for local development, you can use SQLite)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd mdwiki-org-scripts
  2. 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
  3. Set up environment variables: Copy .env.example to .env and fill in the required values.

    cp .env.example .env

Running the Development Server

python src/app1.py

Testing

Tests 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 only

Linting & Formatting

ruff check src/           # Lint
ruff check --fix src/     # Lint with auto-fix
mypy src/                 # Type check
black .                   # Format
isort .                   # Sort imports
pyright src/              # Type check

Line length is 120 across all tools.

Auto Typing

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 # aggressive

Deployment

The application is deployed on Wikimedia Toolforge using Kubernetes. Deployment details and templates are located in the toolforge_tool/ directory.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages