Fix tqdm notebook error in apptainer containers#787
Open
ekatralis wants to merge 1 commit into
Open
Conversation
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue that was introduced in low privilege environments (like lxplus) when using apptainer with IPython 9.13.0
The error originated from a permission issue when importing
tqdm.notebook, which seems unnecessary if we are not running from a notebook environment. This fix changes the import logic to avoid errors in simple imports.This change is important to ensure that cvmfs containers do not crash.
xtrack import error
Traceback (most recent call last): File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_pslinux.py", line 1593, in wrapper return fun(self, *args, **kwargs) File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_common.py", line 377, in wrapper raise err from None File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_common.py", line 375, in wrapper return fun(self) File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_pslinux.py", line 1683, in _parse_stat_file data = bcat(f"{self._procfs_path}/{self.pid}/stat") File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_common.py", line 730, in bcat return cat(fname, fallback=fallback, _open=open_binary) File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_common.py", line 718, in cat with _open(fname) as f: ~~~~~^^^^^^^ File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_common.py", line 682, in open_binary return open(fname, "rb", buffering=FILE_READ_BUFFER_SIZE) PermissionError: [Errno 1] Operation not permitted: '/proc/776109/stat'The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/afs/cern.ch/work/e/ekatrali/private/test_container.py", line 1, in
import xtrack as xt
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/xtrack/init.py", line 14, in
from .tracker_data import TrackerData
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/xtrack/tracker_data.py", line 16, in
from .line import Line, mk_class_namespace, _has_backtrack
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/xtrack/line.py", line 46, in
from .mad_loader import MadLoader
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/xtrack/mad_loader.py", line 38, in
from .progress_indicator import progress
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/xtrack/progress_indicator.py", line 99, in
from tqdm.notebook import tqdm_notebook
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/tqdm/notebook.py", line 23, in
import ipywidgets
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/ipywidgets/init.py", line 27, in
from IPython import get_ipython
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/IPython/init.py", line 56, in
from .terminal.embed import embed
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/IPython/terminal/embed.py", line 16, in
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/IPython/terminal/interactiveshell.py", line 11, in
from IPython.core.kitty import (
...<2 lines>...
)
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/IPython/core/kitty.py", line 36, in
supports_kitty_graphics = _supports_kitty_graphics()
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/IPython/core/kitty.py", line 30, in _supports_kitty_graphics
while process := process.parent():
~~~~~~~~~~~~~~^^
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/init.py", line 608, in parent
if parent.create_time() <= proc_ctime:
~~~~~~~~~~~~~~~~~~^^
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/init.py", line 784, in create_time
self._create_time = self._proc.create_time()
~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_pslinux.py", line 1593, in wrapper
return fun(self, *args, **kwargs)
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_pslinux.py", line 1857, in create_time
float(self._parse_stat_file()['create_time']) / CLOCK_TICKS
~~~~~~~~~~~~~~~~~~~~~^^
File "/home/xsuiteuser/xsuite-env/lib/python3.13/site-packages/psutil/_pslinux.py", line 1595, in wrapper
raise AccessDenied(pid, name) from err
psutil.AccessDenied: (pid=776109)