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

Ouverte
#181 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Refactorisation
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
javascript, json, python

Piste de recherche

Commencez par lire generate_from_specs.py et l’implémentation actuelle de file_formats.py, car file_formats constitue la base des autres migrations. Examinez les tests existants et les modules générés modernes afin de comprendre les modèles attendus pour les specs et la sortie. Le travail est considéré comme terminé lorsque les cinq modules utilisent des specs et des fichiers Python/JavaScript générés, et que le nettoyage des ressources legacy ainsi que de la configuration et de la documentation associées est terminé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
7
Forks
38
Merge moyen
1 j 3 h
PR mergées (30 j)
7

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de learningequality/le-utils

Toutes les issues de learningequality/le-utils

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.