Programming

1. Run Month

"""
The one command you run every month.

    python manage.py run_month data/raw/2026-09-01.xlsb

Idempotent: ingest is keyed on the file hash, marts are rebuilt wholesale.
"""
from django.core.management import call_command
from django.core.management.base import BaseCommand


class Command(BaseCommand):
    help = "Ingest a new month, rebuild everything, render the report."

    def add_arguments(self, parser):
        parser.add_argument("path")
        parser.add_argument("--lang", default="ru")
        parser.add_argument("--fx", default="nominal")
        parser.add_argument("--force", action="store_true")

    def handle(self, *args, **o):
        call_command("ingest_snapshot", o["path"], force=o["force"])
        call_command("build_marts", fx=o["fx"])
        call_command("render_report", lang=o["lang"], fx=o["fx"])
        call_command("export_marts")
        self.stdout.write(self.style.SUCCESS(
            "done — ship marts_bundle.zip to the server and run import_marts there"))
Helpful? Dislike 0 Log in to react