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

download returns Path objects rather than strings when in_region #595

Open
itcarroll opened this issue Jun 10, 2024 · 3 comments
Open

download returns Path objects rather than strings when in_region #595

itcarroll opened this issue Jun 10, 2024 · 3 comments

Comments

@itcarroll
Copy link
Collaborator

itcarroll commented Jun 10, 2024

The download docs say that the return value shall be a list of strings. When running in_region however, the result is a list of pathlib.PosixPath objects.

import earthaccess
import pathlib

assert earthaccess.__version__ == "0.9.0"
assert earthaccess.__store__.in_region

local = pathlib.Path("data").mkdir(exist_ok=True)
results = earthaccess.search_data(short_name="PACE_OCI_L2_BGC_NRT", count=1)
paths = earthaccess.download(results, local_path=local)
assert isinstance(paths[0], str)

The last assert raises an exception.

@mfisher87
Copy link
Member

Nice catch! Why isn't our type checker catching this though?

) -> List[str]:

I love pathlib though, should we update download() to always return Paths? :)

@itcarroll
Copy link
Collaborator Author

If you want to be fancy, you could return the same type given to you in the local_path argument.

@andypbarrett
Copy link
Collaborator

I like the idea of returning a list of Path objects. I think this would avoid cross platform issues.

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

No branches or pull requests

3 participants