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

Đang mở
#181 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, json, python
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Bắt đầu bằng cách đọc generate_from_specs.py và phần triển khai hiện tại của file_formats.py, vì file_formats là nền tảng cho các đợt migration khác. Xem lại các test hiện có và các module được generate hiện đại để hiểu các pattern spec và output được mong đợi. Công việc được xem là hoàn tất khi cả năm module đều sử dụng specs và các file Python/JavaScript được generate, đồng thời hoàn tất việc dọn dẹp các tài nguyên legacy cùng phần setup và documentation liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
7
Fork
38
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của learningequality/le-utils

Tất cả issue của learningequality/le-utils

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.