-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Various standard modules now have post_solve()
functions with built-in report-writing behavior. There are no command-line options to control this, so users have no easy way to turn this off.
This can be a problem when running iterative models on an HPC system, e.g., I am currently running a model that solves for 2 years of hourly data in each of 6 study periods, which makes about 1 GB of output per iteration. None of that is needed, because I only use a few kB of diagnostic statistics each iteration, which are written by a different module. But all this output burdens the HPC's network file system and could slow down the iterations -- they only take a couple of minutes each when running a lot of solutions in parallel, but may take much longer when the file system is backlogged.
I am able to turn off a lot of output by leaving out switch_model.reporting
, but it's not so easy to turn off the post_solve()
functions in the standard modules. I am currently doing that from one of my custom modules via monkey-patching, as follows:
# suppress standard reporting to minimize disk access (ugh)
from importlib import import_module
for module in [
'balancing.load_zones', 'generators.core.build', 'generators.core.dispatch',
'generators.extensions.storage'
]:
imported_module = import_module('switch_model.' + module)
del imported_module.post_solve
But this is not a good long-term solution.
I would recommend moving these standard outputs into the reporting module, and having it 'duck type' the outputs, i.e., only generate outputs for components that are present in the model, and not worry about the others. Then these outputs can be suppressed simply by omitting the reporting module. This would also move reporting to a higher level ("report this element if present, regardless of what module created it"), which would make the output more standardized (roughly the same outputs whether you use the standard modules or some alternative replacements) and avoid repetition of reporting code in alternative models.
I would also recommend adding some command-line flags to control the level of reporting -- per-variable outputs, per-expression outputs, only certain variables and expressions, horizontal-table output or only certain horizontal-table output.