spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
72 stars 17 forks source link

Templates for Data stores #2927

Open soininen opened 1 month ago

soininen commented 1 month ago

Some models, e.g. SpineOpt and FlexTool, offer "templates" for their input data structures. These templates come in the form of .json files that have been exported from Database editor and contain the "non-data" parts of the input data, that is, entity classes, parameter definitions, value lists etc. Some data, like certain model specific entities may be included as well.

The template can be applied to an empty database by importing the .json in Database editor. This is somewhat cumbersome, however. It would be nice if the template was applied automatically when a new database was created or could be restored easily if the database was accidentally purged. A minimum viable solution would be the ability to bind a Data store to a template. If such binding exists, the template is applied when a new database is created using the Data store. There should also be an action to apply the template to the current database. We may also want to have a check that compares the database to given template to check if they match.

At some point an idea was floated (by @manuelma if I remember correctly) that such template system could be based on specifications. This idea is worth exploring, as Data store specifications would be readily available in the Toolbar and could be readily made available through the plugin system.

jkiviluo commented 3 weeks ago

This should also consider multiple templates, but that could be implemented in a 2nd phase. One of them should be the default template. It should also be easy to purge DB with a template (replace current content with the template).