Closed nwesem closed 2 months ago
Thanks for the issue. I think it is a good move to use None as default value.
It is very possible that some of the exporters can be affected, but if so it is likely quite easy fixed. We have some test-cases that use min/max but I do not think they are that thorough.
I suggest - do the change - if there are no regressions reported we assume that there are no generators/tools are affected. If you have a lot of time you can off course add some extra tests on min/max for all generators like we do for some other concepts to be able to catch more regressions but I do not see that as mandatory.
If you get any regression in a tool and it is not obvious for you how to fix it let me know and I can take a look
Hi everyone,
I ran into an issue with the way variables are initialized in the VSSNode class. In this case variables
min
andmax
are the problem. For vspec2id we are creating a 4-byte hash using multiple attributes (name/path, unit, type, datatype, enum values/allowed, or minimum/maximum). This is the waymin
andmax
(and other) are initialized (line 79/80).https://github.com/COVESA/vss-tools/blob/109b3edb5b2a2a0b0abec0852a23996da274e67a/vspec/model/vsstree.py#L35-L92
Now if the minimum value for e.g. a percentage is 0 and the
min
value is implicitly tansformed to an integer (which means it was set from a vehicle specification) and you want to export to a file using one of the exporters we mostly do something likeif node.min: ...
.https://github.com/COVESA/vss-tools/blob/109b3edb5b2a2a0b0abec0852a23996da274e67a/vspec/vssexporters/vss2id.py#L97-L100
These if-clauses will evaluate to False for an integer with value 0 which causes the 4-byte hash to be different. So in other words if we iterate on a static UID file (we impemented a validation to iterate static UID files), the
min
value would not be exported to file causing a different ID in the next iteration of the file.What I suggest is we change all initializations of variables that are not strings e.g.
min
andmax
to use optional None so for python >= 3.10:By doing so we know if the value has been set from a vehicle specification / overlay and if not it will stay None and therefore will not be exported. So on the export we would do sth like
if node.min is not None: ...
I'm creating this issue because I'm wondering if any other exporters work the same way which could cause missing
min
andmax
values (or other?) on iterated vehicle specification files