Rewrite exp list history to avoid using inspect.stack#867
Rewrite exp list history to avoid using inspect.stack#867
Conversation
Co-authored-by: Aaron Brewster <[email protected]>
for more information, see https://pre-commit.ci
|
Thanks @dwpaley. Reading https://docs.python.org/3/library/sys.html#sys._getframe I see that I want to test this in a few production environments (dev build DIALS, release build DIALS, CCP4 DIALS, conda DIALS...) just to be sure we are getting what we expect. Might take a little while to get on to it, but it's on my list. |
dagewa
left a comment
There was a problem hiding this comment.
Success with DIALS (cmake) bootstrap build, release build, and DIALS installed from conda. Can't easily check CCP4 DIALS yet as it's on DIALS 3.21 and doesn't have the required code for the experiment history. But I think if there's any problems there we can make a special case for that later on.
So, I'm happy, but I think a fallback to inspect.stack() is a good idea if someone installs DIALS in some weird environment where sys._getframe does not exist. Plus needs a newsfragment.
This looks like we are fine, because it seems to imply it is always present in CPython. However, we should at the very least check |
Calling inspect.stack() appears harmful in a medium-sized (512 ranks) MPI job because every rank hits the filesystem to resolve module absolute paths. This was causing hangs of up to 5 minutes. Here we switch to sys._getframe to work around the problem.