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

Reading FSFile fails with TypeError #1605

Closed
gerritholl opened this issue Mar 19, 2021 · 2 comments · Fixed by #1606
Closed

Reading FSFile fails with TypeError #1605

gerritholl opened this issue Mar 19, 2021 · 2 comments · Fixed by #1606

Comments

@gerritholl
Copy link
Collaborator

gerritholl commented Mar 19, 2021

Describe the bug

Trying to pass FSFile objects to satpy.Scene results in a TypeError.

To Reproduce

import satpy
from fsspec.implementations.local import LocalFileSystem

satpy.Scene(filenames=[satpy.readers.FSFile("dummy", fs=LocalFileSystem())])

Expected behavior

I expect satpy to process the files (in this case resulting in FileNotFoundError or a related warning message).

Actual results

Traceback (most recent call last):
  File "/home/gholl/checkouts/protocode/mwe/typeerror-fsfile.py", line 5, in <module>
    satpy.Scene(filenames=[satpy.readers.FSFile(["dummy"], fs=LocalFileSystem())])
  File "/data/gholl/miniconda3/envs/py39/lib/python3.9/site-packages/satpy/scene.py", line 108, in __init__
    self._readers = self._create_reader_instances(filenames=filenames,
  File "/data/gholl/miniconda3/envs/py39/lib/python3.9/site-packages/satpy/scene.py", line 157, in _create_reader_instances
    return load_readers(filenames=filenames,
  File "/data/gholl/miniconda3/envs/py39/lib/python3.9/site-packages/satpy/readers/__init__.py", line 460, in load_readers
    remaining_filenames = set(filenames or [])
TypeError: unhashable type: 'FSFile'

Environment Info:

  • Satpy Version: 0.26.0

Additional context

Is this bad enough to make a 0.26.1 release?

@djhoese
Copy link
Member

djhoese commented Mar 19, 2021

I'm confused at how this doesn't work and isn't tested. Isn't this the intended usage?

@gerritholl
Copy link
Collaborator Author

gerritholl commented Mar 19, 2021

The bug was introduced in dfeb067 by @gerritholl. I don't know how adding __eq__ makes a type unhashable, and I also don't know how this is not tested. But seeing that I introduced it, I will fix it.

@gerritholl gerritholl self-assigned this Mar 19, 2021
gerritholl added a commit to gerritholl/satpy that referenced this issue Mar 19, 2021
FSFile objects had been inadvertently made unhashable by
pytroll#1582 .  Make FSFile objects
hashable again by implementing a __hash__ method.

- [x] Fixes pytroll#1604
- [x] Fixes pytroll#1605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants