Migrate legacy constants from JSON-as-data to spec + code generation

Offen
#181 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Refactoring
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
javascript, json, python

Rechercherichtung

Beginne mit dem Lesen von generate_from_specs.py und der aktuellen Implementierung von file_formats.py, da file_formats die Grundlage für die anderen Migrationen bildet. Überprüfe die vorhandenen Tests und die modernen generierten Module, um die erwarteten Spec- und Ausgabemuster zu verstehen. Als abgeschlossen gilt die Arbeit, wenn alle fünf Module Specs und generierte Python/JavaScript-Dateien verwenden und die Bereinigung der Legacy-Ressourcen sowie der zugehörigen Setup- und Dokumentation abgeschlossen ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Overview

Five constant modules (file_formats, licenses, content_kinds, format_presets, languages) are hand-written Python that loads JSON from le_utils/resources/, and the two have to be kept in sync by hand. The JSON files were meant to make these constants available to JS too, but they were never published in the kolibri-constants npm package. They should move to spec/ files built by scripts/generate_from_specs.py, like the repo's other constants and schemas, which already reach JS that way. Studio could then delete deploy/generatejsconstantfiles.py, and Studio and Kolibri could import these constants from kolibri-constants. The Python API stays unchanged, except where an existing value is wrong.

Scope
  • Migrate file_formats, licenses, content_kinds, format_presets and languages to generated modules.
  • Remove le_utils/resources/ from the package; keep le_utils/resources/languagelookup.json in the repo as a symlink to its spec file, so external links still resolve.
  • Excluded: switching Studio and Kolibri to the npm package (follow-up in those repos).
Guidance
Strategy
  • Migrations land one at a time: #182 (generator support and file_formats), then #183, #184, #185, #186, #187.
  • Constant names and choices labels stay as they are. They can't be derived from ids (HTML5 = "zip", CC_BY = "CC BY", (MP4, "MP4 Video")).
  • Generated lists keep their current order: RENDERABLE_PRESETS_ORDER derives bitmask positions that are already saved from the order of PRESETLIST.
  • Each correction to a wrong value is listed in CHANGELOG.md.
Testing Requirements
  • #182 adds a test that pins the public Python API of the five modules as it is before migration.
  • Every migration keeps that test passing; a correction updates the pinned value in the same PR.
Acceptance Criteria
  • file_formats, licenses, content_kinds, format_presets and languages are generated from spec/, and nothing under le_utils/constants/ reads le_utils/resources/.
  • Each of those modules is importable as kolibri-constants/<Module>.
  • The pinned-API test passes, and CHANGELOG.md lists every value that changed.
  • The built le-utils wheel contains no resources/ JSON, and le_utils/resources/languagelookup.json remains in the repo as a symlink to its spec file.

AI usage

I chose the scope, the one-at-a-time order, the rule that only correctness fixes may break the API, and the JS conventions. Claude Code checked the earlier issue text against main and against Studio, Kolibri and ricecooker, then drafted the sections for my edits.

Vorherrschende Sprache
Python
Sterne
7
Forks
38
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
7

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus learningequality/le-utils

Alle Issues in learningequality/le-utils

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.