You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
temp_sys_path removes by index and drops the wrong entry if sys.path is modified while a check is loaded #3753
I hit a strange issue when one of our checks tried to use EasyBuild as a library to resolve a toolchain hierarchy. I suddenly got:
ERROR: run session stopped: key error: 'GCC'
ERROR: KeyError: 'GCC'
When running the same commands interactively, I saw no issues. The root cause turns out to be a modification to the sys.path made by reframe: easybuild searches the sys.path to located the toolchains, and the modification caused this to not be found.
Fundamentally, the issue is this:
reframe.utility.temp_sys_path appends a path on enter and removes it on exit by index:
The pop happens by position. This means that if anything that is run with temp_sys_path modifies the sys.path itself, the wrong thing gets popped by reframe. That happened here: EasyBuild inserts a temporary face_vsc at sys.path[0], and the site-packages dir that contained the toolchains for EasyBuild got popped by reframe upon __exit__. The path that reframe 'temporarily' entered in the __enter__ block was actually left behind.
I realize this type of usage is a bit exotic. On the other hand there are two relatively easy fixes to make this more robust:
Pop by value
Store and restore a sys.path checkpoint
The second solution is the most robust, as it would even undo changes to the sys.path that may have been made by tests.
Note that we have a workaround in place (calling search_toolchain('') right after the EasyBuild import, before temp_sys_path modified the sys.path), so it's not super urgent to fix this - but I guess this could be made more robust before the next person hits it. These errors are rather hard to debug :)
Activity