Spine-Toolbox icon indicating copy to clipboard operation
Spine-Toolbox copied to clipboard

spinedb_api method to advertise db changes or auto refresh cache on commit

Open DillonJ opened this issue 1 year ago • 2 comments

From my understanding of our discussions on the toobbox developer call today, it is my understanding that a tool needs to do something deliberately to tell DB Editor that the data has changed and so the cache needs to be updated. Apologies if I have not understood this correctly. The specific example was the importer tool - which tells DB Editor when it is done, to update.

My understanding is that if we use a Python or Julia tool, which many people do and which we support, then DB Editor is not made aware that the data has changed and so neither reloading the datastore nor restarting db editor refreshes the cache.

This strikes me as being somewhat not ideal. It feels like a user or workflow developer should not need to worry about letting DB Editor know that data has changed. It feels like this is something that should happen automatically any time a commit is made regardless of the source of the commit. Is this something that spinedb_api should do? Whenever there is a commit, spinedb_api broadcasts a message to all db editors. Maybe this is difficult to accomplish.

Alternatively, perhaps we could document some boiler plate code that needs to be included in a Julia or Python tool that does what importer does?

Again, sorry if I haven't understood all of this correctly.

Thoughts @soininen @manuelma @PekkaSavolainen @jkiviluo @PiispaH

DillonJ avatar Aug 15 '23 10:08 DillonJ

We could periodically check if new commits have appeared in the database. This would be a sign that someone outside Toolbox has modified the database.

soininen avatar Aug 15 '23 10:08 soininen

I think the problem is that a tool is executed in separate environment from Spine Toolbox and the messaging is not straightforward. But maybe Spine Engine could be made to do this when the tool is executed from Spine Toolbox (users can of course also execute tools without Toolbox and that's going to require something else, like what Antti is saying).

jkiviluo avatar Aug 15 '23 10:08 jkiviluo