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

Console output truncation #1271

Open nnhjy opened 3 years ago

nnhjy commented 3 years ago

The Julia console in the toolbox for running SpineOpt models truncates its output when there are too many lines while the executions of the tool are progressing normally.

To reproduce the performance, one could use this SpineOpt system: test_sys.zip. The following output should occur in the corresponding Julia console:

Window 565: 2021-07-08T00:00~>2021-07-08T08:00
Setting integers and binaries...  0.013048 seconds (98.99 k allocations: 4.183 MiB)
Updating variables...  0.048615 seconds (157.83 k allocations: 5.951 MiB, 47.81% gc time)
Fixing variable values...  0.020770 seconds (138.53 k allocations: 6.540 MiB)
Updating constraints...  0.004449 seconds (27.19 k allocations: 2.098 MiB)
Updating user constraints...  0.000000 seconds
Updating objective...  0.000010 seconds
Excessive output truncated after 524368 bytes.Optimizing model 75FI_test_transport...  0.006201 seconds (17.81 k allocations: 2.006 MiB)

Below shows a handy fix on this in the Julia script for the tool specification where the syntax run_spineopt() is called:

using IJulia
if isdefined(Main, :IJulia) && Main.IJulia.inited
    IJulia.set_max_stdio(1 << 20)
end

m = run_spineopt(...)

I suspect such a restriction exists also in the Python console as it seems we are using IPython to support consoles (correct me if I'm wrong). Maybe we can put an option in the Settings-->Tools panel about the console output limits.

manuelma commented 3 years ago

Nice one @nnhjy

Thanks very much for that snippet. I think we can use it in toolbox. I still think the maximum stdio can be a settings because sometimes truncation is useful.