Skip to content

Add, rename and delete

A component of a Pywr model is used by name in many places. The extension follows those names, so that adding, renaming and deleting a component does not leave the model broken.

  1. Run Pywr: Add a component from the Command Palette, or press Ctrl Alt P, then A.

    The Add a component command listing the kinds of component to add: node, edge, parameter and the others.The Add a component command listing the kinds of component to add: node, edge, parameter and the others.
  2. Pick the kind of component.

  3. Answer the questions that follow. They depend on the kind:

    Component You are asked for
    Node, virtual node, parameter, recorder, timeseries A name and a type
    Edge The node it starts from, a slot when the node has more than one, and the node it goes to
    Output A type, the metric sets to save, a file name and, for CSV, the format
    Metric set What to include
    Table A type, how values are looked up, and the file
    Scenario A name and a size
    The first question when adding a node: an input box asking for its name.The first question when adding a node: an input box asking for its name.

The component is added to the JSON file with the default values of its type, and its form opens so that you can change them.

You can also:

  • press the + button next to a group in the Model view, to add a component of that kind
  • run the command for one kind, such as Pywr: Add A New Parameter
  • drag a node type onto the schematic
  1. Start the rename from wherever you are:

    • hover the component in the sidebar and press the Rename button
    • press F2 on its name, or on a place that uses it, in the JSON file
    • press Rename in the toolbar of its form
    • right-click the node on the schematic and pick Rename
  2. Type the new name and press Enter. A name that is already used is refused.

The name is changed where the component is defined and in every place that uses it.

Right-click a component in the sidebar and pick Find usages, or press Shift F12 on its name in the JSON file. Each place is listed with its line, and you can click one to go to it.

The JSON editor listing the places where a parameter is used, with a preview of each.The JSON editor listing the places where a parameter is used, with a preview of each.

To see the chain of components, not only the names, use the Dependencies view.

  1. Hover the component in the sidebar and press the Delete button. You can also use the Delete button of its form, or select it on the schematic and press Delete.

  2. Read the confirmation. When other components still use the one you are deleting, the message says how many, and offers to show you where.

  3. Confirm to delete it.