kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Migrate kolibri-sentry-plugin into the Python monorepo

Open rtibbles opened this issue 7 months ago • 3 comments

Overview

Migrate the kolibri-sentry-plugin from its standalone repository (learningequality/kolibri-sentry-plugin) into the Kolibri monorepo as a member of the python_packages/ workspace. Unlike kolibri-sync-extras-plugin, this plugin contains frontend code in addition to Python, so the migration also extends the pnpm workspace to cover python_packages/*.

This is the second per-plugin migration under #13720, building on the monorepo setup completed in #14663.

Complexity: Medium Target branch: develop

Context

kolibri-sentry-plugin is one of the most frequently used Kolibri plugins internally. Its standalone repository contains:

  • A Python package (kolibri_sentry_plugin/) with a kolibri_plugin.py, options, settings, and locale data.
  • A frontend portion (kolibri_sentry_plugin/assets/) with package.json declaring the plugin as private: true. The JS depends on @sentry/vue and on workspace packages already in the Kolibri monorepo (kolibri, kolibri-plugin-data, browserslist-config-kolibri).
  • A setup.cfg / setup.py build config, pre-commit config, and CI.

The plugin's frontend code is bundled into the Python package's wheel at build time (the standard Kolibri plugin pattern); there is no separate npm publish for it.

The Kolibri monorepo's existing pnpm-workspace.yaml already lists kolibri/plugins/* as workspace members, which is the precedent for "Python plugin with embedded JS workspace package". Extending the same pattern to python_packages/* lets a single directory under python_packages/ hold both the Python and JS bits of a plugin.

The Change

Code migration:

  • The contents of learningequality/kolibri-sentry-plugin are moved into python_packages/kolibri-sentry-plugin/ in this repository.
  • setup.cfg / setup.py are replaced with a pyproject.toml consistent with the conventions established by #14663. The plugin gets its own static version field (independent of the main Kolibri version, per the versioning decision in #14663).
  • The plugin's package.json is preserved at python_packages/kolibri-sentry-plugin/package.json. It remains private: true — the JS is bundled into the wheel at build time, not published to npm.
  • Repo-local files that no longer apply (the standalone CI under .github/, Makefile, MANIFEST.in, CONTRIBUTING.rst, .pre-commit-config.yaml) are dropped — they are subsumed by the monorepo's equivalents. The plugin's code must conform to the monorepo's pre-commit config (ruff, per #14457).

Git history:

The migration preserves git history by running git filter-repo --to-subdirectory-filter python_packages/kolibri-sentry-plugin on a fresh clone of the source repo, then merging into the monorepo with git merge --allow-unrelated-histories (the procedure from https://developers.netlify.com/guides/migrating-git-from-multirepo-to-monorepo-without-losing-history/, established by #14663). Historical commit hashes are rewritten — acceptable because the source repo is archived as part of this task.

Workspace integration:

  • pnpm-workspace.yaml is extended to include python_packages/* as workspace members so the plugin's package.json is recognized by pnpm and its workspace dependencies (kolibri, kolibri-plugin-data, etc.) resolve to the local packages. This change is general — it benefits any future Python member package with a frontend, not just sentry.
  • The plugin is added to the python_packages/* glob in the uv workspace config, so uv sync resolves it.
  • The plugin is added to the explicit publishable-packages list in the PyPI publishing workflow (created in #14663).

Build / CI:

  • The plugin's existing build commands (kolibri-tools build prod --plugins kolibri_sentry_plugin) continue to work via the monorepo's existing JS tooling.
  • The plugin's Python tests (if any) run under the Stage 2 per-member-package test job (per #14663). If the plugin has no tests, this is a no-op for now.
  • The plugin's wheel build is verified end-to-end before merge — installing the resulting wheel into a fresh virtualenv and confirming the plugin loads under Kolibri.

External repository:

  • The original learningequality/kolibri-sentry-plugin repository is archived once the migrated version successfully publishes to PyPI from the monorepo.

Out of Scope

  • Migrating any other external plugin — handled by separate per-plugin tasks under #13720.
  • Adding new functionality to the Sentry plugin — this is a like-for-like migration.
  • Changes to how the JS bundle is produced or how the plugin is loaded by Kolibri.
  • Publishing the plugin's frontend code to npm — it remains private: true and ships only inside the wheel.

Acceptance Criteria

Code migration

  • [ ] Plugin code lives at python_packages/kolibri-sentry-plugin/, including the Python module (kolibri_sentry_plugin/) and package.json.
  • [ ] A pyproject.toml replaces setup.cfg / setup.py, follows the conventions established by #14663, and declares an explicit static version field.
  • [ ] Standalone-only files (.github/, Makefile, MANIFEST.in, CONTRIBUTING.rst, .pre-commit-config.yaml, setup.cfg, setup.py) are not present in the migrated directory.
  • [ ] The migrated code passes the monorepo's pre-commit config (ruff and others) without per-file ignores.
  • [ ] Plugin history is preserved via git filter-repo --to-subdirectory-filter; git blame on migrated files traces back to the original commits.

Workspace integration

  • [ ] pnpm-workspace.yaml includes python_packages/* as a workspace glob.
  • [ ] pnpm install from the repo root resolves the plugin's workspace dependencies (kolibri, kolibri-plugin-data, etc.) to local workspace packages.
  • [ ] The plugin appears as a member of the uv workspace; uv sync --group dev includes it.
  • [ ] The plugin is added to the publishable-packages list in the PyPI publishing workflow created by #14663.

Build and runtime

  • [ ] kolibri-tools build prod --plugins kolibri_sentry_plugin produces the JS bundle in the expected location under the migrated directory.
  • [ ] A wheel built from python_packages/kolibri-sentry-plugin/ installs into a fresh virtualenv alongside Kolibri.
  • [ ] After installation, Kolibri loads the plugin without errors and Sentry integration is observable (e.g. a deliberately raised exception reaches the configured Sentry DSN, verified manually).

Tests

  • [ ] If any tests exist in the migrated plugin, they run under the Stage 2 per-member-package job (per #14663) and pass.

External repository

  • [ ] After the migrated plugin successfully publishes to PyPI from the monorepo, the original learningequality/kolibri-sentry-plugin repository is archived.

References

  • Source repository: https://github.com/learningequality/kolibri-sentry-plugin
  • Existing precedent for "Python plugin with embedded JS workspace package": kolibri/plugins/* (already covered by pnpm-workspace.yaml)
  • pnpm workspaces: https://pnpm.io/workspaces
  • uv workspaces: https://docs.astral.sh/uv/concepts/projects/workspaces/

AI usage

Used Claude Code to draft this issue iteratively from a brief prompt. I drove scope and decisions throughout — confirming the single-directory layout for plugin code with frontend, deciding the pnpm-workspace.yaml change belongs in this issue rather than #14663 (because sync-extras didn't need it), and confirming static versioning, pre-commit conformance, and end-to-end wheel verification including manual Sentry integration check. Claude reviewed both source repos, surfaced the structural difference between sentry (with frontend) and sync-extras (Python-only), and edited drafts before each was accepted.

rtibbles avatar Apr 30 '26 23:04 rtibbles

Hello @rtibbles, can i work on this issue?

NihalShinde4933 avatar Jun 02 '26 09:06 NihalShinde4933

Hi! 👋

Thanks so much for your interest! This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.

We really appreciate your willingness to help. 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Jun 02 '26 09:06 learning-equality-bot

Plan: Move learningequality/kolibri-sentry-plugin into this monorepo at python_packages/kolibri-sentry-plugin/, preserving git history, converting it to a uv/pnpm workspace member with a pyproject.toml, and verifying its frontend build and wheel install work end-to-end — mirroring the precedent set by kolibri-sync-extras-plugin (#14663) but extending it to a plugin with frontend code.

  • [ ] Merge upstream history into python_packages/kolibri-sentry-plugin/
  • [ ] Replace setup.cfg/setup.py with pyproject.toml; drop standalone-only files
  • [ ] Register python_packages/* as a pnpm workspace glob; adapt the plugin's package.json
  • [ ] Verify the frontend build and wheel packaging end-to-end
  • [ ] Wire into the PyPI publishing workflow

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Jul 03 '26 00:07 rtibblesbot