Skip to content

Add a --load mode to backpopulate_ovs_data for local dev - #4397

Open
mbertrand wants to merge 5 commits into
mainfrom
mb/ovs-load-command
Open

mbertrand wants to merge 5 commits into
mainfrom
mb/ovs-load-command

Conversation

@mbertrand

@mbertrand mbertrand commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What are the relevant tickets?

N/A. Follow-up to #4384.

Description (What does it do?)

Since #4384, only the data platform's OVS webhook loads OVS videos, so a local stack has no way to get any. This adds --load to backpopulate_ovs_data to seed them from the OVS public API.

  • Pages through ${OVS_API_BASE_URL}/api/v0/public/videos/?include_in_learn=true and skips videos that aren't Complete (the API returns only public ones)
  • Checks each video with the webhook's serializer, OVSVideoWebhookRequestSerializer, then loads it with the webhook's loader, load_ovs_video_from_webhook, so the legacy ETL doesn't come back. A video the serializer rejects is skipped, with its errors on stderr.
  • Refuses unless (ovs, video_playlist) and (ovs, video) are owned by the webhook, the same check the webhook makes before it writes
  • Clears the views cache after loading, as the webhook does
  • Defines OVS_TYPES once in learning_resources/etl/ovs.py, so the webhook view, sweep_empty_ovs_playlists and --load check the same ownership rows

It's meant for local seeding. In deployed environments the webhook still loads OVS, and a refused push is resent from Dagster (runbook).

How can this be tested?

On local-dev (ol-infrastructure's Tilt stack), with this branch checked out in the mit-learn clone Tilt builds:

  1. Add the OVS settings to local-dev/apps/mit-learn/configmaps/app-env.local.yaml in ol-infrastructure (copy it from app-env.local.yaml.example if you don't have one). The pods roll on their own.
    data:
      OVS_API_BASE_URL: "https://video-rc.odl.mit.edu"
      OVS_ALLOWED_MEDIA_HOSTS: '[".cloudfront.net"]'
  2. This should fail with The webhook does not own ovs/video_playlist, video…:
    kubectl --context local-dev exec -n mit-learn deploy/mitlearn-webapp -c app -- python manage.py backpopulate_ovs_data --load
    
  3. In Django admin, add ETLSourceOwnership rows for ovs/video_playlist and ovs/video with owner webhook.
  4. Run step 2's command again. It should print Loaded N OVS videos, skipped M, and the videos should show up in search once the celery worker has indexed them. Running it again shouldn't create duplicates.

I ran this on local-dev against RC (passing the two settings on the command line instead of the ConfigMap): the first run refused, then --load loaded 130 videos into 2 playlists, all 130 were indexed in OpenSearch, and a second run left the counts unchanged. pytest learning_resources/management/commands/backpopulate_ovs_data_test.py passes.

Since #4384 only the data platform's OVS webhook loads OVS videos, so a
local stack had no way to get any. --load fetches the OVS public API
(include_in_learn=true, following pages), keeps the removed extract's
public/Complete filter, and runs each video through the webhook's loader
under the webhook pipeline. It refuses unless (ovs, video_playlist) and
(ovs, video) are owned by the webhook, so it can't write where the push
wouldn't.
@mbertrand
mbertrand requested a review from a team as a code owner November 25, 2026 15:01
Copilot AI balanced review requested due to automatic review settings November 25, 2026 15:01

@agent-optibot agent-optibot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds local seeding of OVS videos through the public API.

  • Adds: --load mode to seed OVS videos from the public API.
  • Changes: loading to follow API pages, skip non-public or incomplete videos, and use load_ovs_video_from_webhook.
  • Changes: loading to require webhook ownership of OVS playlists and videos before writing.
Details for reviewers

Core files: learning_resources/management/commands/backpopulate_ovs_data.py

More changes

  • Adds: tests for pagination, filtering, ownership checks, and loaded video results. (backpopulate_ovs_data_test.py)

Unchanged

  • Existing transcript fetching and OVS video deletion modes remain available.

Summary of 6aa0ff7 · React 👍 or 👎 on my comments to tune what I raise · Commands · Review config

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@agent-optibot agent-optibot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status: Code Looks Good 👍

No blocking issues found.

📌 Reviewed up to the latest commit · ⏱️ Review completed in 3 minutes

  • 🔄 re-review this PR

--load now runs each video through OVSVideoWebhookRequestSerializer, the
check the webhook makes before loading, and skips the ones it rejects
instead of writing them or stopping the run. It clears the views cache
afterward as the webhook does, and its refusal message says to add the
ownership rows, which a fresh database doesn't have.
OVS_TYPES now lives in learning_resources/etl/ovs.py, and the webhook
view, sweep_empty_ovs_playlists and --load all import it, so they can't
check different ownership rows. The --load test now asserts the second
request goes to the page's next url, and its ownership helper drops a
parameter every call passed the same value.
@mbertrand mbertrand added the Needs Review An open Pull Request that is ready for review label Nov 25, 2026
@mbertrand mbertrand changed the title Add a --load mode to backpopulate_ovs_data Add a --load mode to backpopulate_ovs_data for local dev Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants