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
69 stars 17 forks source link

Run several tools in the same console #1647

Open manuelma opened 2 years ago

manuelma commented 2 years ago

At the moment each tool runs in isolation in the sense it uses its own console. Tools don't share consoles. The reason is, basically, that tools need to define variables and we don't want anything overwritten.

However, there are cases where it would be useful for tools to share consoles, for example, when a workflow has several tools that run different instances of SpineOpt. If all of them run in isolation, they need to compile SpineOpt individually and that takes time. If we could set all these tools to use the same console, SpineOpt needs to be compiled only once.

jkiviluo commented 2 years ago

One should be able to link a tool item with a console instance. However, I don't know how this would play with parallel scenario runs.

manuelma commented 2 years ago

What I did for now is I added one line edit to the tool properties to enter what I called the 'group id'. If you want multiple tools to use the same console, you need to write the exact same group id string for all of them. Note that if you do this for tools that can run in parallel, it may happen that both run concurrently on the same console (and that can be very bad).

Filters (aka parallel scenario runs) are an exception.

toolprops

soininen commented 2 years ago

Would it be possible to somehow guard against dangerous group ids at least on Toolbox level? On that note, could that text field be also be a 'search field' for existing ids? Edit: i.e. some kind of autofill would be appreciated

manuelma commented 2 years ago

I like those suggestions a lot @soininen, and they should be easy to implement. Will give it a try.

(To check for dangerous group id we just need to check if there are parallel tools using the same group id - and to check for parallel tools, we just need to check if there's a directed path betwen them which is straitghforward with networkx)