Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(system-server): add /system/oem_mode/upload_splash endpoint to change boot splash #14865

Merged
merged 16 commits into from
Apr 12, 2024

Conversation

vegano1
Copy link
Contributor

@vegano1 vegano1 commented Apr 11, 2024

Overview

Now that we can enable/disable OEM mode, we need an endpoint to upload an image file which will become the splash screen. This pull request adds the endpoint, which takes a file and validates it to make sure it's a PNG image, < 5 MB in size, and is 1024x600 in dimension. Once validated, the file is saved to its final location in /var/lib/opentrons-system-server/oem_mode/{filename} then we update OT_SYSTEM_SERVER_oem_mode_splash_custom dotenv file with the same location.

Closes: PLAT-277

Test Plan

  • Make sure we only process the request if OEM mode has been enabled
  • Make sure we only handle valid images, png, <5mb
  • Make sure that we can upload a PNG image that gets stored in /var/lib/opentrons-system-server/oem_mode/{filename}
  • Make sure that we set the OT_SYSTEM_SERVER_oem_mode_splash_custom to /var/lib/opentrons-system-server/oem_mode/{filename} in the system.env file
  • Make sure that the splash screen changes after rebooting the system

Changelog

  • added /system/oem_mode/upload_splash endpoint to the system server

Review requests

Risk assessment

Low, unreleased

@vegano1 vegano1 changed the base branch from edge to PLAT-276-add-oem-mode-endpoint April 11, 2024 04:58
@vegano1 vegano1 requested review from a team, brenthagen and CaseyBatten April 11, 2024 04:58
file_size = 0
for chunk in file.file:
file_size += len(chunk)
if file_size > 5242880: # 5MB
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we make this the literal sequence 5 * 1024 * 1024

@vegano1 vegano1 requested a review from sfoster1 April 11, 2024 19:36
@vegano1 vegano1 marked this pull request as ready for review April 11, 2024 19:36
@vegano1 vegano1 requested review from a team as code owners April 11, 2024 19:36
add import-untyped for typefile import
@vegano1 vegano1 removed the request for review from brenthagen April 12, 2024 18:35
Base automatically changed from PLAT-276-add-oem-mode-endpoint to edge April 12, 2024 19:28
Copy link
Contributor

@CaseyBatten CaseyBatten left a comment

Choose a reason for hiding this comment

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

Looks good and links together as expected based on robot-server side changes as well, flow for client->system server endpoint relationship makes sense from discussions on how the behavior is split between the two.

detail="File is larger than 5mb.",
)

# TODO: Validate image dimensions
Copy link
Contributor

Choose a reason for hiding this comment

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

This TODO can be removed since we will no longer be validating dimensions on this side.

Comment on lines +55 to +62
status.HTTP_201_CREATED: {"message": "OEM Mode splash screen uploaded"},
status.HTTP_400_BAD_REQUEST: {"message": "OEM Mode splash screen not set"},
status.HTTP_413_REQUEST_ENTITY_TOO_LARGE: {
"message": "File is larger than 5mb"
},
status.HTTP_415_UNSUPPORTED_MEDIA_TYPE: {"message": "Invalid file type"},
status.HTTP_500_INTERNAL_SERVER_ERROR: {
"message": "OEM Mode splash unhandled exception."
Copy link
Contributor

Choose a reason for hiding this comment

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

Status responses all make sense and are error codes in line with what would reasonably be expected on receiving end.

@vegano1 vegano1 merged commit 5c4c9fe into edge Apr 12, 2024
31 checks passed
@vegano1 vegano1 deleted the PLAT-277-add-oem-splash-logo-endpoint branch April 12, 2024 20:27
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants