-
Notifications
You must be signed in to change notification settings - Fork 388
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 support broken for some GeoDatasets if directory does not exist #1605
Comments
Before 0.5.0, each (individual) method # GeoDataset
@property
def files(self) -> set[str]:
... # unchanged code removed
files: set[str] = set()
for path in paths:
if os.path.exists(path):
if os.path.isfile(path):
files.add(path)
else: # meaning os.path.isdir(path) == True, since exists is checked
pathname = os.path.join(path, "**", self.filename_glob)
files |= set(glob.iglob(pathname, recursive=True))
else:
files |= self.handle_nonlocal_path(path)
return files
@staticmethod
def handle_nonlocal_path(path: str) -> set:
return set() With this setup the user must make sure the files are available (as before 0.5.0). They can download files, unpack zips etc. Or they can implement their own logic by overriding Proposed docstring:
Running I have a branch reflecting these changes. I'll wait with the PR until we have discussed the approach. |
I don't like this because it makes it impossible to use remote/zip files without the user overriding I think you already looked into this and found that it wasn't possible to confirm whether a file was remote/zip vs. local? Like the path may not always contain vsi or something like that. But will the path always contain a colon? What if we check both I agree that P.S. Would love to have better support for glob chars. Something like |
I did not realise until now the the There are two ways of specifying vsi-path, one without any commas. But I have looked at this before, something similar may be feasible. I'll be back. |
FYI I was able to use v0.5 to do COG reading with RasterDataset -- https://gist.github.com/calebrob6/df765911d86df6c648e99060222b1e0b |
Drafted up a proposition in #1612 . |
Would this replace the (btw, looks like something similar are coming to vsi (?) ) |
Nope, it wouldn't replace it. We still need the ability to set a default filename glob for subclasses of RasterDataset. But this would allow people to override it without creating a subclass. This is a feature people frequently request: #1524 |
Yes, I meant override, not replace 👍 |
Description
@adriantre this is a bug we (mostly I) introduced in #1442/#1597. The issue is that if
os.path.isdir(file)
is False, we automatically add the file toself.files
, and thenself.files
evaluates to True in_verify
. I think the safest solution is to not useself.files
in_verify
, but you might be able to think of a better solution.I first noticed this during 8ec2e93 but didn't realize the impact of it until fe546bf. I still want to get this release out so I figured I would give us something to do in 0.5.1. I don't know how many other datasets are impacted.
Current workaround is to create the directory before downloading. Not hard, just annoying.
Steps to reproduce
Version
0.5.0
The text was updated successfully, but these errors were encountered: