-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: be more cautious when guessing what a backend can open #10804
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
Open
ianhi
wants to merge
21
commits into
pydata:main
Choose a base branch
from
ianhi:fix-netcdf4-remote-zarr-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2af21ab
fix: be more more caution when claiming a backend can open a URL
ianhi 1a3e7df
add whats new entry
ianhi d6a47b7
fixes from review
ianhi 7ed1f0a
more caution in scipy netcdf backend
ianhi 60c1158
correct suffix detection for scipy backend
ianhi d2334e4
stricter URL detection for netcdf/dap
ianhi ef3e07c
no query params for h5netcdf
ianhi c07e7ea
scipy no urls
ianhi 017713b
Merge branch 'main' into fix-netcdf4-remote-zarr-detection
ianhi 9cf669b
don't try to read magic numbers for remote uris
ianhi e0e2da2
Merge branch 'main' into fix-netcdf4-remote-zarr-detection
ianhi bfefb21
Merge branch 'main' into fix-netcdf4-remote-zarr-detection
ianhi a50b2f6
review comments
ianhi 10d6edd
fix windows failures
ianhi 8c77986
docs on backend resolution
ianhi 079b290
more complete table
ianhi 6ee2910
no horizontal scroll on table
ianhi 418ceee
Merge branch 'main' into fix-netcdf4-remote-zarr-detection
ianhi e32e93a
fix whats new header
ianhi f445045
correct description
ianhi 4a717e7
case insensitivity to DAP: vs dap:
ianhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from collections.abc import Iterable | ||
from typing import TYPE_CHECKING, Any | ||
|
||
|
@@ -209,7 +210,23 @@ class PydapBackendEntrypoint(BackendEntrypoint): | |
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.PydapBackendEntrypoint.html" | ||
|
||
def guess_can_open(self, filename_or_obj: T_PathFileOrDataStore) -> bool: | ||
return isinstance(filename_or_obj, str) and is_remote_uri(filename_or_obj) | ||
if not isinstance(filename_or_obj, str): | ||
return False | ||
|
||
# Check for explicit DAP protocol indicators: | ||
# 1. DAP scheme: dap2:// or dap4:// (case-insensitive, may not be recognized by is_remote_uri) | ||
# 2. Remote URI with /dap2/ or /dap4/ in URL path (case-insensitive) | ||
# Note: We intentionally do NOT check for .dap suffix as that would match | ||
# file extensions like .dap which trigger downloads of binary data | ||
url_lower = filename_or_obj.lower() | ||
if url_lower.startswith(("dap2://", "dap4://")): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mikejmnez is it ok that this will accept both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I tried it and it works with pydap. same for DAP4 v dap4 |
||
return True | ||
|
||
# For standard remote URIs, check for DAP indicators in path | ||
if is_remote_uri(filename_or_obj): | ||
return "/dap2/" in url_lower or "/dap4/" in url_lower | ||
|
||
return False | ||
|
||
def open_dataset( | ||
self, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally not stripping any query params that might be present in dap query so that h5netcdf does not claim to be able to open it, as it's my undersstanding that it cannot