Ribasim icon indicating copy to clipboard operation
Ribasim copied to clipboard

Extend Ribasim Python API with Update function

Open gijsber opened this issue 1 year ago • 3 comments

When you have existing models, you might want to update the model parameterization without rebuilding the model.

Therefore an Update API would be usefull, A design would be needed, but in my mind you want to say something like:

Update(table ,[ids], [content]) where table incidcates the table to update [ids] references the nodes (or edges) to be updated [content] holds the updated dataset (complete, not partial), structured according to the table definition and ordered by the ids. [ids] and [content] could be organized in tuples, dictionaries or whatever is efficient.

gijsber avatar Jul 02 '24 07:07 gijsber

If the node type stays the same this should be relatively easy. More complicated functionality would be supporting also replacing node types, removing nodes, and all the other features of the Ribasim 7 network editor.

If this is used for scenarios it also links to #47.

visr avatar Jul 02 '24 09:07 visr

Here is code that updates an existing node_id to a new node_type with data, implemented in the Ribasim-NL Model class: https://github.com/Deltares/Ribasim-NL/blob/7a413d8ef9b09d8365b47888753674874efa2bf7/src/ribasim_nl/ribasim_nl/model.py#L106-L144

DanielTollenaar avatar Jul 04 '24 06:07 DanielTollenaar

We essentially require schema migrations, using something like https://alembic.sqlalchemy.org/en/latest/.

evetion avatar Aug 22 '24 12:08 evetion