-
Notifications
You must be signed in to change notification settings - Fork 1
Adding a method to get options #72
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
base: main
Are you sure you want to change the base?
Conversation
@@ -337,3 +337,21 @@ def test_determine_input_type_in_create(self): | |||
# this won't work because there are multiple input types that could be mapped to the serial_number field | |||
with self.assertRaises(ValueError): | |||
FrameGrabberConfig.create(serial_number="1234567890", resolution_width=640, resolution_height=480, digital_zoom=2) | |||
|
|||
# def test_get_and_apply_options(self): |
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 uncomment this test? I dont think we should leave it in if we're just going to keep it commented.
@@ -284,6 +284,13 @@ def create(cls, input_type: Optional[InputTypes] = None, **kwargs) -> "FrameGrab | |||
continue | |||
raise ValueError("Could not determine input type from provided arguments") | |||
|
|||
def get_options(self) -> dict: |
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.
If you want this to actually be grabber.config.options
, then you could use the @Property decorator and call this def options(self):
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.
I considered this, however sometimes the rpc server tries to do things like this:
grabber.config.options["some_option"] = "new value"
This works if grabber.config.options is actually a property, but raises an exception if it is a method decorated with property.
In general, I try to stay away from the property decorator for this reason. I would rather know if something is a method or a property.
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.
That said, maybe the RPC server shouldn't be updating options like that. We need to figure out the right way to update options, especially in light of the recent pydantic refactor.
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.
LGTM, see comment about test
Roxanne raised some concerns about this PR, so we'll put it on pause until we agree on a path forward. |
The latest pydantification of framegrab broke some applications that interact with grabber options like this:
config is now a pydantic object and cannot be accessed in this way.
I realized that there is no straightforward way in the new pydantic version of framegrab to get options, so I added a method. Now you can do this: