Skip to content

Feat/diff - #521

Open
jdacoello wants to merge 12 commits into
COVESA:masterfrom
jdacoello:feat/diff
Open

Feat/diff#521
jdacoello wants to merge 12 commits into
COVESA:masterfrom
jdacoello:feat/diff

Conversation

@jdacoello

Copy link
Copy Markdown
Contributor

It implements two main things:

  • A compose command to take a snapshot of the model to persist a stand alone immutable state
  • A diff command to compare and report the differences between two snapshots

Comment thread src/vss_tools/compose.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in "exporters" folder but it is not an exporter, or?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I've just moved it to the parent directory.

Comment thread docs/compose.md Outdated
|---|---|---|
| `model_snapshot.vspec` | The full model tree | Yes |
| `structs_snapshot.vspec` | Custom struct type definitions | Only when `--types` is given |
| `units_snapshot.yaml` | Resolved units | Only when units are provided |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit unsure on how to interpret "Only when units are provided". File also produced when using default unit file, see example below

.venv-vss) erik@vbox:~/vehicle_signal_specification$ vspec compose -s spec/VehicleSignalSpecification.vspec -o tmp
[15:06:58] INFO     Loaded 'VSSQuantity', file=/home/erik/vehicle_signal_specification/spec/quantities.yaml, elements=30                                                                                                                units_quantities.py:34
           INFO     Loaded 'VSSUnit', file=/home/erik/vehicle_signal_specification/spec/units.yaml, elements=69                                                                                                                         units_quantities.py:34
           INFO     VSpecs loaded, amount=91                                                                                                                                                                                                      vspec.py:130
[15:06:59] INFO     Composing vspec model into tmp...                                                                                                                                                                                           compose.py:124
           INFO     VSpecs loaded, amount=91                                                                                                                                                                                                      vspec.py:130
           INFO     Signal tree written to tmp/model_snapshot.vspec                                                                                                                                                                             compose.py:135
           INFO     Loaded 'VSSUnit', file=/home/erik/vehicle_signal_specification/spec/units.yaml, elements=69                                                                                                                         units_quantities.py:34
           INFO     Units written to tmp/units_snapshot.yaml                                                                                                                                                                                    compose.py:160
           INFO     Loaded 'VSSQuantity', file=/home/erik/vehicle_signal_specification/spec/quantities.yaml, elements=30                                                                                                                units_quantities.py:34
           INFO     Quantities written to tmp/quantities_snapshot.yaml    

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. The reason for that is because the vss-tools have a fallback behavior if no units or quantity are explicitly passed. They read the default expected location for units and quantities. I updated the docs.

Comment thread docs/compose.md
@erikbosch

Copy link
Copy Markdown
Collaborator

MoM:

  • D presented the PR
  • D will show demo next week
  • Please review
  • E: Shall we run compose for every release
  • D: Yes, shall be mandatory
  • E: We can look at that after the PR is merged
  • D: Would be good with a minor release after this is merged.
  • V: Wondering on automatic triggering

Comment thread src/vss_tools/cli.py
@click.group(context_settings={"auto_envvar_prefix": "vss_tools"}, invoke_without_command=True)
@click.group(
cls=LazyGroup,
lazy_subcommands={

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the lazy annotations here. Just make the commands "normal" ones by using @cli.command annotations for them

Comment thread src/vss_tools/compose.py
# output remains a valid, re-parseable vspec.
SNAPSHOT_EXCLUDE_FIELDS = ["delete", "fqn", "is_instance"]

MODEL_SNAPSHOT_FILENAME = "model_snapshot.vspec"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would get rid of _snapshot

Comment thread src/vss_tools/compose.py
QUANTITIES_SNAPSHOT_FILENAME = "quantities_snapshot.yaml"


def _filter_raw_node(attrs: dict[str, Any], exclude_fields: list[str]) -> dict[str, Any]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/vss_tools/diff.py


def load_flat_yaml(path: Path) -> dict[str, Any]:
"""Load a flat snapshot YAML file. Returns empty dict when file is absent."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what means flat?

Comment thread src/vss_tools/diff_cmd.py
out_text = json.dumps(result, indent=2, ensure_ascii=False)

if output:
output.write_text(out_text, encoding="utf-8")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we do a json.dump here?

@erikbosch

Copy link
Copy Markdown
Collaborator

MoM:

  • Daniel checking comments

Comment thread docs/compose.md

## What it does

A vspec model is typically spread across many files: a main `.vspec`, optional `#include` files, overlays, a units file, and a quantities file. `vspec compose` collapses all of that into a single **self-contained folder** (a _snapshot_) that any downstream `vspec export` command can consume without needing the original source tree.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth stating the differences compared to the "vspec export yaml" command, because they have some similarities, right? Like long term, do we need both?

@erikbosch

Copy link
Copy Markdown
Collaborator

MoM:

  • Shall not be merged until model ledger merged and package created
  • Feel free to test out

@erikbosch

Copy link
Copy Markdown
Collaborator

MoM:

@erikbosch

Copy link
Copy Markdown
Collaborator

COnflicts

@erikbosch

Copy link
Copy Markdown
Collaborator

Any updates on the status of this one @jdacoello

jdacoello added 11 commits July 23, 2026 13:36
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
…itities

Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
…irst-run mode support

Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
… logic

Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
@erikbosch

Copy link
Copy Markdown
Collaborator

What is the current status @jdacoello

@erikbosch

Copy link
Copy Markdown
Collaborator

MoM:

  • JD: Ledger dependency missing
  • JD: Will set up call with @erikbosch , will add ledger package to pypi
  • E: Friday or Monday afternoon works

@erikbosch erikbosch mentioned this pull request Jul 31, 2026
Signed-off-by: JD Alvarez <8550265+jdacoello@users.noreply.github.com>
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