Update CameraMimeType to allow for custom mimes#995
Merged
njooma merged 3 commits intoviamrobotics:mainfrom Sep 5, 2025
Merged
Update CameraMimeType to allow for custom mimes#995njooma merged 3 commits intoviamrobotics:mainfrom
njooma merged 3 commits intoviamrobotics:mainfrom
Conversation
Contributor
|
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
stuqdog
approved these changes
Sep 3, 2025
Comment on lines
+12
to
+23
| class _FrozenClassAttributesMeta(type): | ||
| """ | ||
| A metaclass that prevents the reassignment of existing class attributes. | ||
| """ | ||
|
|
||
| def __setattr__(cls, name: str, value: Any): | ||
| # Check if the attribute `name` already exists on the class | ||
| if name in cls.__dict__: | ||
| # If it exists, raise an error to prevent overwriting | ||
| raise AttributeError(f"Cannot reassign constant '{name}'") | ||
| # If it's a new attribute, allow it to be set | ||
| super().__setattr__(name, value) |
hexbabe
reviewed
Sep 4, 2025
| raise NotImplementedError() | ||
|
|
||
| async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> List[Geometry]: | ||
| async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> Sequence[Geometry]: |
Member
There was a problem hiding this comment.
Curious why these Sequence changes? Does it type-hint grpc repeated sets better?
Member
Author
There was a problem hiding this comment.
Yea exactly -- a superset of list that allows us to save some casts
| assert img4.width is None | ||
| assert img4.height is None | ||
|
|
||
| img5 = ViamImage(b"data", CameraMimeType.CUSTOM(self.UNSUPPORTED_MIME_TYPE)) |
Member
There was a problem hiding this comment.
should we test to_proto on an unsupported mime somewhere?
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.
This PR should supersede #993 and #982
Change the functionality of
CameraMimeTypeso that it is not limited only to predetermined values, but has the ability to addCUSTOMvalues ofCameraMimeTypethat can be used everywhere in the code.CameraMimeTypecontinues to behave as astreverywherestris accepted, while having additional properties and methods, includingnameandvalueproperties, which give it the same properties as the previousEnum-type.This should prevent the mime-type changes from being a breaking change.