Page 1 of 1

Reporter Behavior

Posted: Wed Oct 30, 2019 1:54 pm
by gideonsimpson
I was working with a custom reporter from within iPython, and I noticed something that I'd like to clarify. My reporter just makes measurements of the system and writes them to a text file at the specified interval. I observed that, in iPython, if I did

Code: Select all

[1] %run openmm_script.py
I would find that my text file would sometimes be empty or not have recorded every step. If I quit iPython, it wrote as expected, and if I instead just did

Code: Select all

$ python openmm_script.py
at the command line, it behaved as expected. It seems like the reporters (or at least my custom one) only flush when a particular event is triggered. I was wondering if someone could clarify how this is controlled (assuming this is normal behavior).

Re: Reporter Behavior

Posted: Wed Oct 30, 2019 2:00 pm
by peastman
That's entirely up to the reporter. If it opens a file for writing, it has complete control of what gets written to the file. It sounds like you want to add a call to flush() at the end of report()?