-
Notifications
You must be signed in to change notification settings - Fork 67
Update CameraMimeType to allow for custom mimes #995
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
Conversation
|
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
stuqdog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, lgtm!
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh this is clever
| 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]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why these Sequence changes? Does it type-hint grpc repeated sets better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we test to_proto on an unsupported mime somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
hexbabe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
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.