Skip to content

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

Open
0 of 6 issues completed
Open

Description

@rtibbles

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

Testing Requirements

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions