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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

the earthaccess.EarthAccessFile wrapper need not subclass anything #620

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

itcarroll
Copy link
Collaborator

@itcarroll itcarroll commented Jun 26, 2024

Fixes #610, closes #563.

This PR removes any base class from the definition of earthaccess.EarthAccessFile (EAF). Previously, EAF inherited from fsspec.spec.AbstractBufferedFile (ABF) so was capable of using methods defined on ABF. But EAF held an instance of an ABF at self.f and handed off __getattr__ requests to that object. Under this setup, self.read returns super().read if read is defined on ABF (and read is defined on ABF) else self.read returns self.f.read. That is a bug. It was probably assumed that __getattr__ would catch all method calls, but it only handles what __getattribute__ can't find.

We've scraped by with this setup because self.f is also an ABF and either does not override ABF on a called method or the override does little more than itself call super(). The latter is the case for self.f.read when f is a fsspec.implementations.http.HTTPFile. It is not the case when f is a fsspec.implementations.http.HTTPStreamFile.

This PR also updates some type hints and relevant documentation.

  • the type hint on f was wrong, it is an ABF not a fsspec.AbstractFileSystem
  • type hints previously given as an ABF are now given as EAF (b/c it is no longer an instance of ABF)
  • the EAF is added to mkdocs un Modules/Store

ToDo if integration tests look okay:

  • add to changelog
  • check for any changes needed to docs

馃摎 Documentation preview 馃摎: https://earthaccess--620.org.readthedocs.build/en/620/

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