improved transcoding workflow for local development#2594
improved transcoding workflow for local development#2594umar8hassan wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @umar8hassan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the video transcoding workflow, particularly for local development and testing. It introduces a robust system for mocking AWS MediaConvert responses, enabling developers to simulate transcoding job completions and failures without relying on actual AWS services. This automation streamlines the testing process, improves error handling, and provides more accurate status tracking for video jobs.
Highlights
- Enhanced Local Transcoding Workflow: Introduced a new Celery task (
update_video_transcoding_statuses) that periodically checks and updates the status of transcoding videos. This task simulates AWS MediaConvert callbacks for local development and testing, using configurable JSON templates for both success and error scenarios. - Dynamic Mocking with Placeholders: Implemented a
prepare_job_resultsutility that dynamically populates mock AWS MediaConvert responses. It replaces placeholders (e.g.,<VIDEO_JOB_ID>,<DRIVE_FILE_ID>,<AWS_ACCOUNT_ID>) in JSON templates with real-time video, job, and environment-specific data, making local testing more realistic and flexible. - Improved Transcoding Status Management: The system now includes a
get_media_convert_jobfunction to retrieve AWS MediaConvert job details and a more resilientupdate_video_jobfunction that handles case-insensitive statuses and gracefully processes output details. TheVideoJobStatusenum was extended with anERRORstatus. - Comprehensive Documentation Updates: The
README.mdandvideos/README.mdfiles have been significantly updated to provide clear instructions and explanations for configuring and utilizing the new local development and testing features, including required environment variables and detailed testing workflows. - New Configuration Options: Several new environment variables have been introduced (
VIDEO_TRANSCODING_STATUS_UPDATE_FREQUENCY,TRANSCODE_RESULT_TEMPLATE,TRANSCODE_ERROR_TEMPLATE,VIDEO_S3_TRANSCODE_BUCKET,POST_TRANSCODE_ACTIONS) to control the frequency of status updates, specify mock result/error templates, and configure post-transcoding actions.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
The code changes introduce an improved transcoding workflow for local development, including periodic status updates and mock AWS MediaConvert callbacks. The changes also include updates to documentation and test files to reflect the new workflow.
| @@ -67,8 +69,11 @@ def create_media_convert_job(video: Video): | |||
| video.save() | |||
|
|
|||
| process_video_outputs(video, results.get("outputGroupDetails")) | ||
| output_group_details = results.get("outputGroupDetails", []) | ||
| process_video_outputs(video, output_group_details) | ||
| except: # pylint:disable=bare-except # noqa: E722 |
There was a problem hiding this comment.
Catching a bare exception is generally discouraged. Consider catching specific exceptions like KeyError, TypeError, or ValueError to handle potential issues more gracefully and avoid masking unexpected errors.1
Style Guide References
| except: # pylint:disable=bare-except # noqa: E722 | |
| except (KeyError, TypeError, ValueError): # pylint:disable=bare-except # noqa: E722 |
Footnotes
|
|
||
| # Decode the JSON string | ||
| try: | ||
| return json.loads(results) |
There was a problem hiding this comment.
Catching a bare exception is generally discouraged. Consider catching specific exceptions like json.JSONDecodeError to handle potential issues more gracefully and avoid masking unexpected errors.1
Style Guide References
| return json.loads(results) | |
| except json.JSONDecodeError: |
Footnotes
| media_convert_job["Job"]["Status"].lower() | ||
| == VideoJobStatus.COMPLETE.lower() | ||
| ): |
There was a problem hiding this comment.
| elif ( | ||
| media_convert_job["Job"]["Status"].lower() | ||
| == VideoJobStatus.ERROR.lower() |
There was a problem hiding this comment.
| if results is not None: | ||
| for action in settings.POST_TRANSCODE_ACTIONS: | ||
| import_string(action)(results.get("detail", {})) |
What are the relevant tickets?
Description (What does it do?)
This PR address the Phase - 1: of the linked issue which involves the following steps:
environment = dev:If the task does
NOTinvolve testing Transcoding with MediaConvert, simply copy/paste the original video in the locations to mock the Transcoding taskenvironment = staging:If the task involves testing Transcoding with MediaConvert, submit the task to AWS and mock the callback on completion. This would involve the following steps:
How can this be tested?
TBA