Open JanStreffing opened 1 month ago
It is indeed weird, some time ago I coded a stream for observe that will get the output from observe compute, and only write it when the simulation is finished. Somehow, that's broken now?
Thanks for reporting.
This has been like this for quite a while for me. Maybe half a year or more. Does that fit timeline wise?
I don't know, other than the workflow manager, I don't know of another thing it could have changed that. Do you see that for all versions of FESOM right?
Not just FESOM, here is an example from a standlone oifs 48r1 simulation:
I can confirm this, and I think I also know where it is happening. We migrated logging to the loguru
library a while ago, if I am not mistaken, and all logs are now dumped into sys.stdout
:
We need to reconsider this, in particular I would in general like to overhaul the logging to make it cleaner between all the various tools. I am not sure when @mandresm or I will have time for that, though.
Good point @pgierz! The good news is that it's probably really easy to solve :)
Before using loguru
we were using print commands and the standard logger, and we had a problem: the observe
step runs at the same time the models are running, and printing/logging at the same time of the models. This was a mess. I solved the problem a while ago by creating https://github.com/esm-tools/esm_tools/blob/release/src/esm_runscripts/logfiles.py
That took care of writing all the stdout/err of observe
into: 1) a stream 2) on the fly into the observe log, and 3) dumping the stream into the stdout of the script when the simulation was finished.
My feeling is that we can remove https://github.com/esm-tools/esm_tools/blob/release/src/esm_runscripts/logfiles.py, but we will need to configure loguru so that for observe
(https://github.com/esm-tools/esm_tools/blob/release/src/esm_runscripts/observe.py) it can write both to the observe
log and into a stream that is then put into the model stdout.
@pgierz, can you take this issue under your wing? If that's the case please have a look at https://github.com/esm-tools/esm_tools/blob/release/src/esm_runscripts/logfiles.py, maybe you get some ideas from there into how to implement a similar behavior with loguru
. Then we can get rid of the logfiles.py
.
the entry point for all of this is in the SimulationSetup.__call__
:
https://github.com/esm-tools/esm_tools/blob/release/src/esm_runscripts/sim_objects.py#L124
There one calls initialize_logfiles
function which uses the RuntimeLogger
, the one that takes care of handling the stream:
The RuntimeLogger
object is used again to dump it's stream into the general log file:
https://github.com/esm-tools/esm_tools/blob/release/src/esm_runscripts/sim_objects.py#L156
I'll look into this...
For some time now I find, that esm_tools output is written into stdout at model startup. To me this makes debugging model crashes harder, as unrelated monitoring info is interspersed. I am under the impression, that this output used to go somewhere else.
Here is an example: