-
Notifications
You must be signed in to change notification settings - Fork 17
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
Update parser to match language as defined in README.md #25
Conversation
@@ -289,7 +308,9 @@ def ast_Arguments(parent, yamltree, argtype = 'in_arguments') -> list[Argument]: | |||
for st in subtrees: | |||
node = Argument(get_yaml_value(st, 'name'), parent) | |||
node.description = get_yaml_value(st, 'description') | |||
node.type = get_yaml_value(st, 'datatype') | |||
node.datatype = get_yaml_value(st, 'datatype') |
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.
We should preferably check how this change affect existing templates. For example, we have a regression for https://github.com/COVESA/vsc-tools/blob/master/templates/simple_overview.tpl as it refers to {{x.type}}
. Have not checked output of other templates if there are any more regressions.
(With this PR we can later extend templates to also consider error information, but for now it is enough that we do not introduce any regressions)
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.
We should preferably check how this change affect existing templates
Yes. The "existing templates" in /templates are controlled by the same code project and the intention was to update them accordingly, of course. In other words, it's a bug that the change to the template was not included in the push.
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.
Daniel Wilms and have done some prototyping for a test framework for VSS to detect regressions (see e.g. COVESA/vss-tools#159, Daniel has been working on a similar concept using Python). Would be great if we later could add something similar so VSC-tools so regressions to templates would be detected by CI.
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.
Agree, that could be useful, probably in combination with traditional unit tests based on input + expected output!
I would probably build out some more traditional tests first and add this "diffing against previous output" when there are more feature-full templates, and things have stabilized a bit more.
This is now more for reference because I imagine #26 will be the preferred implementation(?) In any case, I'd probably merge this first because it is relevant history. |
@@ -371,28 +412,44 @@ def ast_Properties(parent, yamltree) -> list[Property]: | |||
for st in subtrees: | |||
node = Property(get_yaml_value(st, 'name'), parent) | |||
node.description = get_yaml_value(st, 'description') | |||
node.type = get_yaml_value(st, '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.
I notice that "type" (i.e. sensor/attribute (and actuator?)) has been removed from the vsc README for properties, but is still used within the VSC seat example. If that is intentional we shall better remove it from the example.
(Or do we need to have something similar to attribute/sensor/actuator for properties in VSC, if not using those words maybe something like r/rw. We say in readme that "Each properties list object specifies a shared state object that can be read and set, and which is available to all subscribing entities.", so it seems that properties shall be writeable)
model/vsc_parser.py
Outdated
@@ -305,6 +326,7 @@ def ast_Members(parent, yamltree, argtype = 'members') -> list[Member]: | |||
node = Member(get_yaml_value(st, 'name'), parent) | |||
node.description = get_yaml_value(st, 'description') | |||
node.type = get_yaml_value(st, 'datatype') |
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.
Shall also be changed to datatype?
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 changed this and squashed it into the original commit and force pushed.
I would prefer that the regressions in at least simple_overview.tpl are fixed before merge. |
Fixed type->datatype in 3e419de and it seems to be generated now. |
I think this is ready to be merged as an intermediate step, but #26 (major rewrite) would also be rebased on top of it. Either way you look at it, we would keep this step as a part of the history, as discussed above. |
Since #28 was merged first, I had to rebase this. @waltersve, could you please check that the changes in 9751408 seem to be correct since in the meantime I had already (in 3e419de) modified type to datatype based on @erikbosch input above. |
We should also get more testing up and running, hopefully. The (very rudimentary) unit test failed because major/minor version were included in the BAMM code and are now mandatory, but were missing in the test input. Added fix above. Now it's successful. |
templates/sds-bamm-macros.tpl
Outdated
@@ -176,8 +174,8 @@ a bamm-c:RangeConstraint ; | |||
{{ member.name }} | |||
{%- elif member.datatype and member.datatype.endswith("_t") -%} | |||
Characteristic{{ snake_to_camel(member.datatype.capitalize()) }} | |||
{%- elif member.type and member.type.endswith("_t") -%} | |||
Characteristic{{ snake_to_camel(member.type.capitalize()) }} | |||
{%- elif member.datatype and member.datatype.endswith("_t") -%} |
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.
The lines 177-178 can actually be removed now when it is unified that "datatype" always is "datatype" (previously it was called "type" for attributes") so the workaround here can be removed
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.
Ok. Will do. Thanks for the hint.
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, that was what I intended and I removed the if-conditions in a few places, but may have missed some. I didn't try to understand your logic much before, but I guess now that you were using _t suffix as a condition to see if it was a data type or an attribute?
@@ -188,6 +186,6 @@ Characteristic{{ snake_to_camel(member.name.capitalize()) }} | |||
{%- if member.datatype -%} | |||
:{{ snake_to_camel(member.datatype.capitalize()) }} | |||
{%- else -%} | |||
:{{ snake_to_camel(member.type.capitalize()) }} | |||
:{{ snake_to_camel(member.datatype.capitalize()) }} |
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.
And here I assume line 186-188+190 can be removed
Signed-off-by: Gunnar Andersson <gunnar@[email protected]>
First change to update parser to match current description of the VSC syntax (as stated in README.md of vehicle_service_catalog, _currently_) (There could still be some bugs in either this code, and/or the description in the README)
This is to match the variable name in the code now. It might be necessary to do another update of templates in combination with the next iteration of the parser, a.k.a. "data driven" parser.
The changeset that added BAMM output generator included major-version and minor-version, that were missing from the parser. They were included as mandatory fields, so the rudimentary test failed. (I would have squashed this change into the same changeset but they were already merged)
OK, template sds-bamm-macros.tpl is now updated with Erik's help, and the PR cleaned up and rebased on master -> ready to merge. |
Meeting decision to merge |
First change to update parser to match current description of the VSC
syntax (as stated in README.md of vehicle_service_catalog, currently)
(There could still be some bugs in either this code, and/or the description in the README, but this brings the tools at least roughly up to date with what is described there).