Skip to content
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

Merged
merged 4 commits into from
Jun 22, 2022

Conversation

gunnarx
Copy link
Collaborator

@gunnarx gunnarx commented Apr 27, 2022

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).

@@ -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')
Copy link
Contributor

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)

Copy link
Collaborator Author

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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.

@gunnarx
Copy link
Collaborator Author

gunnarx commented May 9, 2022

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')
Copy link
Contributor

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)

@@ -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')
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@erikbosch
Copy link
Contributor

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.

I would prefer that the regressions in at least simple_overview.tpl are fixed before merge.

@gunnarx
Copy link
Collaborator Author

gunnarx commented Jun 13, 2022

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.

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.

@gunnarx
Copy link
Collaborator Author

gunnarx commented Jun 13, 2022

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.

@gunnarx
Copy link
Collaborator Author

gunnarx commented Jun 13, 2022

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.

@gunnarx
Copy link
Collaborator Author

gunnarx commented Jun 13, 2022

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.

@gunnarx gunnarx mentioned this pull request Jun 13, 2022
@@ -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") -%}
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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()) }}
Copy link
Contributor

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

Gunnar Andersson and others added 4 commits June 20, 2022 12:25
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)
@gunnarx
Copy link
Collaborator Author

gunnarx commented Jun 20, 2022

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.

@erikbosch
Copy link
Contributor

Meeting decision to merge

@gunnarx gunnarx merged commit ddd2895 into COVESA:master Jun 22, 2022
@gunnarx gunnarx deleted the update_parser branch August 4, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants