-
Notifications
You must be signed in to change notification settings - Fork 7
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
Hide OneOfSchema Attributes #139
Conversation
Signed-off-by: Matthew F Leader <[email protected]>
Signed-off-by: Matthew F Leader <[email protected]>
Signed-off-by: Matthew F Leader <[email protected]>
Signed-off-by: Matthew F Leader <[email protected]>
Signed-off-by: Matthew F Leader <[email protected]>
Signed-off-by: Matthew F Leader <[email protected]>
Signed-off-by: Matthew F Leader <[email protected]>
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 like Dave's suggestion (assuming it addresses the problem).
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.
Looks good. I haven't tested it with a plugin.
For comparison, attached are the manually generated files of the Stress-NG plugin schema using the sdk's To reproduce: ❯ mkdir testdir
❯ cd testdir
❯ git clone https://github.com/arcalot/arcaflow-plugin-sdk-python.git
❯ git clone https://github.com/arcalot/arcaflow-plugin-stressng.git
❯ cd arcaflow-plugin-sdk-python/src
❯ cp -r ../../arcaflow-plugin-stressng/arcaflow_plugin_stressng .
❯ python arcaflow_plugin_stressng/stressng_plugin.py --schema > stressng_schema-main.txt
❯ git switch oneof-attrs-privatize
❯ python arcaflow_plugin_stressng/stressng_plugin.py --schema > stressng_schema-oneof-attrs-privatize.txt
❯ diff stressng_schema-main.txt stressng_schema-oneof-attrs-privatize.txt
760,761d759
< discriminator_type: string
< oneof_type: _discriminated_string_
2367,2368d2364
< discriminator_type: string
< oneof_type: _discriminated_string_ GitHub doesn't want me to upload a |
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.
Oh, cool. 😁
Changes introduced with this PR
All attributes on the *Schema classes, like
OneOfStringSchema
orOneOfIntSchema
, inschema.py
must be public because the schema builder portion ofschema.py
uses metadata analysis of that class's attributes to determine if an instance of the Arcaflow type has been written as specified by the Arcaflow type system (implemented by the *Schema classes and a few other parts of this code base). As a language feature of Python, classes do not have private/hidden attributes. If a private attribute must exist on a *Schema class, then one solution is to encapsulate the required behavior or state on a part of the class that is not used as a part of the metadata analysis. In this pull request I have encapsulated the state we would like to be hidden within method calls on the relevant classes.Testing for this behavior is not simple, and will have to be introduced in a follow-up pull request.
By contributing to this repository, I agree to the contribution guidelines.