-
Notifications
You must be signed in to change notification settings - Fork 0
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: Parsers Dynamic Configuration #160
base: main
Are you sure you want to change the base?
Conversation
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'm not really in the loop with C++ porting but this LGTM.
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.
Generally LGTM but I'd wait for @moratom to confirm the structure is good for porting
@@ -73,6 +74,19 @@ def __init__( | |||
self.ignored_indexes = ignored_indexes if ignored_indexes is not None else [] | |||
self.remove_duplicates = remove_duplicates | |||
self.concatenate_classes = concatenate_classes | |||
self._configurable_parameters.add( |
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.
This + getters for every setter have to be added also to all other parsers right?
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.
Yes, exactly. I've marked the PR as draft yet, just to confirm the core logic. If approved I'll add the getters and parameters to all the other parsers.
The Parameter
class constructor also takes in optional name
and description
arguments. Those are for now set dynamically. The name
with setter.__name__
and description with setter.__doc__
. This is the most "Python magic" used there. And it may not be okay for porting. Resulting in necessity to also have the name
and description
arguments filled in the Parameter
constructor.
I would not expose all the parameters. Namely those that are set by the NNArchive and their change would break the parser for the model. Examples of such methods are: setOutputLayerName
, setClasses
, setSoftmax
.
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, should be portable to C++.
I do have one question though - how come we went with a completely generic message instead of a strongly typed, per parser message here?
Any downsides for the strongly typed message?
@moratom The reason that the message ( If you know a way how to make it more strongly typed, while still having a way to configure the parameters by user, let me know and I'll adjust the code. |
@dominik737 (I might be missing something here of-course) |
@moratom On the other-side, when user knows the underlying parser type. He can just retrieve the parser from the In the Viewer I could technically have a big switch with all the parsers and their capabilities. But to me it felt as a worse option than having this information provided by the parser itself. |
Implementation of parser dynamic configuration settings and retrieval. Written with intention that the code will be in future ported to C++, hence heavily restricting "Python magic".
The core part of the feature is the
Parameter
class. The class basically contains getter and setter function reference for a configurable parameter e.g.getIgnoredIndexes
&setIgnoredIndexes
. Parser can then expose whichever configurable parameters by simply withself._parameters.add
.The
Parameter
class itself is abstract (cannot be instantiated). To add parameters use it's child classes likeBoolParameter
orIntListParameter
.In Python-only context the child classes would be redundant and everything they do could be done with runtime reflection, type conversions etc., but for C++ they might be necessary.
Retrieving parser configuration is done by calling
configuration
property on a parser. The configuration parameter name, value as string, type as string and description will be returned.Setting the configuration is done with
configuration_input
, which is standarddai.Node.Input
. The input acceptsConfigurationChange
message, inherited fromdai.Buffer
.