Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions xrspatial/geotiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,18 @@ def _read_geo_info(source, *, overview_level: int | None = None,
from ._dtypes import resolve_bits_per_sample, tiff_dtype_to_numpy
from ._geotags import extract_geo_info_with_overview_inheritance
from ._header import parse_all_ifds, parse_header, select_overview_ifd
from ._reader import (
# ``_parse_cog_http_meta`` is imported from ``_cog_http`` directly
# rather than re-routed through ``_reader`` because the
# ``open_geotiff(..., chunks=...)`` fsspec metadata path is not part
# of the ``_reader.*`` monkeypatch surface (no test patches
# ``_reader._parse_cog_http_meta`` and then exercises this branch).
# The eager / dask HTTP paths that ARE patched route through
# ``_cog_http._read_cog_http`` and ``_backends/dask.py``'s
# ``_HTTPSource`` construction, both of which still go through
# ``_reader`` for the patchable names. See PR-J / #2258.
from ._cog_http import _parse_cog_http_meta
from ._sources import (
_CloudSource, _coerce_path, _is_file_like, _is_fsspec_uri,
_parse_cog_http_meta,
)
from ._validation import _validate_predictor_sample_format

Expand Down
18 changes: 12 additions & 6 deletions xrspatial/geotiff/_backends/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ def read_geotiff_dask(source: str, *,
effective_source = source
if is_http or is_fsspec:
import dask
from .._reader import _parse_cog_http_meta
from .._cog_http import _parse_cog_http_meta
if is_http:
# ``_HTTPSource`` is resolved through ``_reader`` so existing
# tests that ``monkeypatch.setattr(_reader, '_HTTPSource', ...)``
# keep intercepting the construction after the COG-HTTP
# helpers moved to ``_cog_http`` (PR-J / #2258).
from .._reader import _HTTPSource
_src = _HTTPSource(source)
else:
Expand Down Expand Up @@ -548,13 +552,15 @@ def _read(http_meta):
from .._reader import _is_fsspec_uri as _ifs
_is_fsspec_src = _ifs(source)
if http_meta is not None and (_is_http_src or _is_fsspec_src):
from .._reader import (
_fetch_decode_cog_http_tiles,
MAX_PIXELS_DEFAULT,
_apply_photometric_miniswhite,
)
from .._cog_http import _fetch_decode_cog_http_tiles
from .._decode import _apply_photometric_miniswhite
from .._layout import MAX_PIXELS_DEFAULT
header, ifd = http_meta
if _is_http_src:
# See PR-J / #2258: keep the per-chunk ``_HTTPSource`` /
# ``_CloudSource`` construction routed through ``_reader``
# so monkeypatches against ``_reader._HTTPSource`` (used
# by the dask-HTTP coalesce tests) still take effect.
from .._reader import _HTTPSource
src = _HTTPSource(source)
else:
Expand Down
Loading
Loading