Open the Command Palette with Ctrl Shift P (Cmd Shift P on macOS) and type Pywr to list the commands.
Most commands are listed only while a model is open. A command marked v2 or v1 is listed only for models of that version.
| Command | What it does |
|---|---|
| Pywr: New model | Creates a model from a template. Always available. |
| Pywr: Edit Model Settings | Opens the form with the title, the period and the time step of the model. |
| Pywr: Set as the Primary Pywr Model | Makes the model the primary model of the workspace. You need an open folder. |
| Pywr: Unset the Primary Pywr Model | Clears the primary model of the workspace. The file is not changed. |
| Pywr: Open the schematic for the active model | Opens the schematic. It is also a button at the top right of the editor and at the top of the Model view. |
| Pywr: Clear Saved Schematic Zoom & Position | Forgets the zoom and the position saved for the schematic of every model. Always available. |
| Pywr: Edit Included Files v1 | Opens the form with the Python files the model includes. |
| Pywr: Manage Cython Modules | Lists the compiled Cython modules imported before a Pywr v1 model is loaded, to add or remove one. Always available. |
| Pywr: Open the documentation | Opens the documentation of Pywr v1, Pywr v2 or this extension in a tab of VS Code. Always available. |
| Pywr: Install the skill for Claude Code | Copies the agent skill of the extension to the skills folder of Claude Code, for all your projects or for a workspace folder. Always available. |
| Pywr: Set up the Python environment | Installs the packages that Pywr v1 or v2 needs in the active Python environment, or in a new .venv in the workspace folder, and checks that they can be imported. Always available. |
Run and results
Section titled “Run and results”| Command | What it does |
|---|---|
| Pywr: Run the model | Runs the model. |
| Pywr: Run the model with options… | Runs the model after you choose the solver, the scenarios and the output folder. |
| Pywr: Run project definition… v2 | Builds the model of a definition of the pywr project open in the editor and opens the model (run a project). |
| Pywr: Edit the project v2 | Opens a form to edit the pywr project in the active editor and build its definitions (run a project). |
| Pywr: Run a risk analysis… | Runs the model from each year of its record and saves the storage of the reservoirs in each run, with their percentiles. |
| Pywr: Deficit analysis v2 | Runs a copy of the model that saves only the deficit of the output nodes with a max_flow and charts it as a calendar. |
| Pywr: Open the results chart | Opens a results file in the results viewer. Always available, and in the right-click menu of .h5, .hdf5, .arrow and .csv files in the Explorer. |
| Pywr: Open the QA report | Opens the QA report of the model. |
| Pywr: Compare model versions | Compares two versions of a model by component, from a git commit or from two files. Also in the right-click menu of .json files in the Explorer. |
Azure DevOps
Section titled “Azure DevOps”These are always available. The pull request commands need the folder to be connected to Azure DevOps.
| Command | What it does |
|---|---|
| Pywr: Connect to Azure DevOps | Asks for the address of the repository and a personal access token, checks them and saves them encrypted in the workspace folder. |
| Pywr: Update the Azure DevOps token | Replaces the personal access token of the connection, for example when it expires. |
| Pywr: Disconnect from Azure DevOps | Deletes the saved connection of the folder and its key. |
| Pywr: Show pull requests | Lists the pull requests you review or created, to see their changes, check them out, vote, complete them or link work items. |
| Pywr: Create a pull request | Creates a pull request from the branch you have checked out. |
| Pywr: Create pull request | Creates the pull request whose description is in the active editor. Only available in that editor, where it is also a button at the top right. |
Python scripts
Section titled “Python scripts”Each of these opens a new, unsaved file with a script to start from (see
Write Python scripts). They are always
available. When a model of the Pywr version of the script is open, its path is written in
the script, with the HDF5 file of its first DataFrameParameter or TablesRecorder.
| Command | What it does |
|---|---|
| Pywr: New Python Script: Run a Pywr v1 Model | Opens a new Python script that loads and runs a Pywr v1 model, then prints the statistics of the run and the results of its recorders. |
| Pywr: New Python Script: Run a Pywr v2 Model | Opens a new Python script that loads and runs a Pywr v2 model and saves its outputs. |
| Pywr: New Python Script: Open the HDF5 File of a DataFrameParameter (Pywr v1) | Opens a new Python script that lists the tables of the pandas HDF5 file read by a DataFrameParameter and prints one of them. |
| Pywr: New Python Script: Open a TablesRecorder File (Pywr v1) | Opens a new Python script that reads the file written by a TablesRecorder with h5py: the time steps, the scenarios and the results of a node or parameter. |
| Pywr: New Python Script: Custom Parameter (Pywr v1) | Opens a new Python file with a documented custom parameter to start from. |
| Pywr: New Cython Module: Custom Parameter (Pywr v1) | Opens a new Cython file with a documented custom parameter, and the steps to build it and use it as a Cython module. |
| Command | What it does |
|---|---|
| Pywr: Add a component | Asks for the kind of component, then adds it. |
| Pywr: Add A New Node | Adds a node. |
| Pywr: Add A New Edge | Adds an edge between two nodes. |
| Pywr: Add A New Parameter | Adds a parameter. |
| Pywr: Add A New Table | Adds a table. |
| Pywr: Add A New Scenario | Adds a scenario. |
| Pywr: Add A New Virtual Node v2 | Adds a virtual node. |
| Pywr: Add A New Metric Set v2 | Adds a metric set. |
| Pywr: Add A New Output v2 | Adds an output. |
| Pywr: Add A New Timeseries v2 | Adds a timeseries. |
| Pywr: Add A New Recorder v1 | Adds a recorder. |
Edit, rename and delete
Section titled “Edit, rename and delete”Each of these asks which component to act on, then opens its form, renames it or deletes it. See Add, rename and delete.
| Component | Edit | Rename | Delete |
|---|---|---|---|
| Node | Pywr: Edit Node | Pywr: Rename Node | Pywr: Delete Node |
| Edge | Pywr: Edit Edge | Pywr: Delete Edge | |
| Parameter | Pywr: Edit Parameter | Pywr: Rename Parameter | Pywr: Delete Parameter |
| Table | Pywr: Edit Table | Pywr: Rename Table | Pywr: Delete Table |
| Scenario | Pywr: Edit Scenario | Pywr: Rename Scenario | Pywr: Delete Scenario |
| Virtual node v2 | Pywr: Edit Virtual Node | Pywr: Rename Virtual Node | Pywr: Delete Virtual Node |
| Metric set v2 | Pywr: Edit Metric Set | Pywr: Rename Metric Set | Pywr: Delete Metric Set |
| Output v2 | Pywr: Edit Output | Pywr: Rename Output | Pywr: Delete Output |
| Timeseries v2 | Pywr: Edit Timeseries | Pywr: Rename Timeseries | Pywr: Delete Timeseries |
| Recorder v1 | Pywr: Edit Recorder | Pywr: Rename Recorder | Pywr: Delete Recorder |
Actions in the sidebar and the editor
Section titled “Actions in the sidebar and the editor”These are not in the Command Palette. You find them where they apply.
| Action | Where |
|---|---|
| Find usages | Right-click a component in the sidebar, or a node on the schematic. In the JSON file, Shift F12. |
| Go to JSON | The button next to a component in the sidebar, and its right-click menu. |
| Show the dependencies | Right-click a component in the sidebar, or the button in its form. |
| Show on schematic | Right-click a node, a virtual node or an edge in the sidebar, or the link above it in the JSON file. |
| Chart the results | Right-click a node, a virtual node or a parameter in the sidebar, or the button in its form. |
| Add to the QA report… | Right-click a node, a virtual node, a parameter or an edge in the sidebar. |
| Pywr: Add to the Cython Modules | Right-click a .so or a .pyd file in the Explorer. |
| Open in default app | The button next to a table that reads a file, in the Model view. |
| Refresh | The top of the Model view. |
| Filter the components, Clear the filter | The top of the Model view. |
| Create the missing component, Rename the duplicated component, Browse for the file | The light bulb on a mistake in the JSON file. |
Pywr for VS Code and Pywr for Azure DevOps are developed and maintained by Stefano Simoncelli.