Skip to content

Compare two versions

A line diff of a model file is hard to read. Moving a component to another place in the file, or formatting the file again, changes many lines even when the model stays the same. Pywr: Compare model versions compares two versions of a model one component at a time. It lists the nodes, edges, parameters and other components that were added, removed or changed, and opens the old and new configuration of a component side by side.

It works for Pywr v2 and Pywr v1 models. The two versions must use the same format.

When the model is in a git repository, you can compare it with any commit that changed it.

  1. Open the model and run Pywr: Compare model versions, from the Command Palette or from the … menu at the top right of the editor.

  2. Pick A git revision of this file…. The list shows the commits that changed the file, with their message, date and author.

    The list of the commits of model.json, each with its message, its short hash, its date and its author.The list of the commits of model.json, each with its message, its short hash, its date and its author.
  3. Pick a commit. The model at that commit is compared with the open model, including the changes you have not saved yet.

To compare two model files, for example a model and a copy with a new option, select both files in the Explorer, right-click one of them and pick Compare model versions. The title of the list shows the old version on the left of the arrow and the new one on its right.

You can also right-click a single model file, or run the command with a model open, and pick Another model file… to choose the file to compare it with.

The changes are listed in three groups:

  • Added: the components that are only in the new version.
  • Removed: the components that are only in the old version.
  • Changed: the components that are in both versions with a different configuration. Under each one, the keys that changed, such as values or max_flow.
The changes between a commit and the open model: a node and its two edges added, the old node and its edges removed, and the metadata and the Northfield demand parameter changed.The changes between a commit and the open model: a node and its two edges added, the old node and its edges removed, and the metadata and the Northfield demand parameter changed.

Components are matched by name, so their order in the file and its formatting are ignored. A renamed component shows up twice: removed under its old name and added under the new one. Edges are named after the nodes they connect, so the edges of a renamed node are removed and added too.

The settings at the root of the model, such as metadata and the time settings, are listed with the type Model.

Type in the box to filter the list by name, by type or by the changed keys.

Pick a component in the list to open its configuration in the old version (left) and in the new version (right), with the differences highlighted. The list stays open for the next component until you press Escape.

The Northfield demand parameter in the old and in the new version side by side, with the monthly values that changed highlighted.The Northfield demand parameter in the old and in the new version side by side, with the monthly values that changed highlighted.

An added component has an empty left side, and a removed one an empty right side.