fix: run Course Optimizer extended-analysis export/upload as a background task - #466
Open
nsprenkle wants to merge 1 commit into
Open
fix: run Course Optimizer extended-analysis export/upload as a background task#466nsprenkle wants to merge 1 commit into
nsprenkle wants to merge 1 commit into
Conversation
…ound task CourseAnalysisReportView.post previously exported and compressed the course, then uploaded it to xpert-ai-workflows, synchronously inside the request thread -- large courses could tie up a Studio web worker long enough to hit a proxy/gateway timeout. Moves that work into a new Celery task (submit_course_analysis_report, mirroring export_olx/LinkCheckView's existing pattern in this module) so the view returns 202 immediately. CourseAnalysisReportStatusView is unaffected -- it already polls xpert-ai-workflows by course id, not run id, so no run-tracking state needed to be added on the Studio side to support this. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #426. A reviewer flagged that
CourseAnalysisReportView.postwas exporting and compressing the course, then uploading it toxpert-ai-workflows, synchronously inside the Studio request thread -- large courses could tie up a web worker long enough to hit a proxy/gateway timeout, and there was no way to bound the export/compress step at all (only the network POST itself had a timeout).This moves that work into a new Celery task,
submit_course_analysis_report, mirroring the existingexport_olx/LinkCheckViewpattern already used elsewhere in this module for exactly this shape of problem (expensive course-scoped work + client polling for status).CourseAnalysisReportView.postnow just enqueues the task and returns202 {"status": "pending"}immediately.CourseAnalysisReportStatusViewis unaffected by this change -- it already pollsxpert-ai-workflowsby course id (GET /courses/{course_id}/runs/latest), not by run id, so no Studio-side run-tracking state needed to be added to support the async POST; the frontend's existing polling already treats "no run yet" as still-pending.Supporting information
Companion PR (same change on the frontend side, though no functional changes were needed beyond removing an unused
runIdfield from the POST response): edx/frontend-app-authoring#114Testing instructions
contentstore.enable_course_optimizer_extended_checkswaffle flag for a test course./api/contentstore/v1/course_optimizer/analysis/{course_id}(e.g. via the frontend's "Start analysis" button) -- it should return202immediately rather than waiting for the export/upload to complete.submit_course_analysis_reportrunning and POSTing toxpert-ai-workflows.pytest cms/djangoapps/contentstore/rest_api/v1/views/tests/test_course_optimizer.py cms/djangoapps/contentstore/tests/test_tasks.pyshould pass.