Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: SDF frontend breaks load() if target file lacks read permission #4286

Closed
Xarthisius opened this issue Jan 9, 2023 · 3 comments
Closed
Labels

Comments

@Xarthisius
Copy link
Member

Xarthisius commented Jan 9, 2023

Bug report

Bug summary

While trying to yt.load() a file without permission SDF._is_valid() yields PermissionError and breaks the detection loop. If we want to check permission in yt.load() itself that'd be fine, but no frontend should die cause of it.

Code for reproduction

(root) $ echo "hello world!" > /tmp/hello.txt
(root) $ chmod og-r /tmp/hello.txt
(user) $ python -c 'import yt; yt.load("/tmp/hello.txt")'

Actual outcome

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xarth/codes/xarthisius/yt/yt/_maintenance/deprecation.py", line 73, in inner
    return func(*args, **kwargs)
  File "/home/xarth/codes/xarthisius/yt/yt/loaders.py", line 112, in load
    if cls._is_valid(fn, *args, **kwargs):
  File "/home/xarth/codes/xarthisius/yt/yt/frontends/sdf/data_structures.py", line 186, in _is_valid
    with open(sdf_header, encoding="ISO-8859-1") as f:
PermissionError: [Errno 13] Permission denied: '/tmp/hello.txt'

Expected outcome

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xarth/codes/xarthisius/yt/yt/_maintenance/deprecation.py", line 73, in inner
    return func(*args, **kwargs)
  File "/home/xarth/codes/xarthisius/yt/yt/loaders.py", line 124, in load
    raise YTUnidentifiedDataType(fn, *args, **kwargs)
yt.utilities.exceptions.YTUnidentifiedDataType: Could not determine input format from '/tmp/hello.txt'

or yt.load raising PermissionError

Version Information

  • Operating System: Ubuntu 20.04
  • Python Version: 3.9
  • yt version: last_yt3-7052-gaf4dbf6b1
@neutrinoceros
Copy link
Member

I suspect SDF may just be the first one that dies on this, but it's likely that other frontends have the same issue.

@matthewturk
Copy link
Member

Can we catch PermissionError early on and fail globally?

@neutrinoceros
Copy link
Member

This was fixed in #4285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants