Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
abarciauskas-bgse committed Jun 4, 2024
1 parent 1aa53e0 commit b68c0c5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
import rasterio
from fastapi.testclient import TestClient
from rio_tiler.models import ImageData

DATA_DIR = os.path.join(os.path.dirname(__file__), "fixtures")

Expand All @@ -30,5 +29,7 @@ def mock_rasterio_open(asset):
"https://noaa-eri-pds.s3.us-east-1.amazonaws.com/2020_Nashville_Tornado/20200307a_RGB",
DATA_DIR,
)
import pdb; pdb.set_trace()
import pdb

pdb.set_trace()
return rasterio.open(asset)
6 changes: 4 additions & 2 deletions tests/test_asset_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ def test_asset_info():
def test_get_reader_any():
"""Test reader is rio_tiler.io.Reader"""
asset_info = AssetInfo(url="https://file.tif")
empty_stac_reader = AssetReader({'bbox': [], 'assets': []})
empty_stac_reader = AssetReader({"bbox": [], "assets": []})
assert empty_stac_reader._get_reader(asset_info) == Reader


@pytest.mark.xfail(reason="To be implemented.")
def test_get_reader_netcdf():
"""Test reader attribute is titiler.stacapi.XarrayReader"""
asset_info = AssetInfo(url="https://file.nc", type="application/netcdf")
empty_stac_reader = AssetReader({'bbox': [], 'assets': []})
empty_stac_reader = AssetReader({"bbox": [], "assets": []})
empty_stac_reader._get_reader(asset_info)


@pytest.mark.skip(reason="Too slow.")
@patch("rio_tiler.io.rasterio.rasterio")
def test_tile_cog(rio):
Expand All @@ -49,6 +50,7 @@ def test_tile_cog(rio):
img = reader.tile(0, 0, 0, assets=["cog"])
assert isinstance(img, ImageData)


@pytest.mark.skip(reason="To be implemented.")
def test_tile_netcdf():
"""Test tile function with netcdf asset."""
Expand Down
8 changes: 5 additions & 3 deletions titiler/stacapi/asset_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from rio_tiler.io.base import BaseReader, MultiBaseReader
from rio_tiler.models import ImageData
from rio_tiler.tasks import multi_arrays
from rio_tiler.types import Indexes

from titiler.stacapi.models import AssetInfo
from titiler.stacapi.settings import CacheSettings, RetrySettings, STACSettings
Expand Down Expand Up @@ -68,8 +67,11 @@ def _minzoom(self):
@maxzoom.default
def _maxzoom(self):
return self.tms.maxzoom

def __attrs_post_init__(self):
"""
Post Init.
"""
# MultibaseReader includes the spatial mixin so these attributes are required to assert that the tile exists inside the bounds of the item
self.crs = WGS84_CRS # Per specification STAC items are in WGS84
self.bounds = self.input["bbox"]
Expand All @@ -86,7 +88,7 @@ def _get_reader(self, asset_info: AssetInfo) -> Type[BaseReader]:
"application/x-netcdf",
"application/netcdf",
]:
raise NotImplementedError("XarrayReader not yet implemented")
raise NotImplementedError("XarrayReader not yet implemented")

return Reader

Expand Down
5 changes: 1 addition & 4 deletions titiler/stacapi/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from urllib.parse import urlencode

import jinja2
import rasterio
from cogeo_mosaic.backends import BaseBackend
from fastapi import Depends, HTTPException, Path, Query
from fastapi.dependencies.utils import get_dependant, request_params_to_args
Expand Down Expand Up @@ -202,9 +201,7 @@ def tile(
reader_options={**reader_params},
**backend_params,
) as src_dst:
if MOSAIC_STRICT_ZOOM and (
z < src_dst.minzoom or z > src_dst.maxzoom
):
if MOSAIC_STRICT_ZOOM and (z < src_dst.minzoom or z > src_dst.maxzoom):
raise HTTPException(
400,
f"Invalid ZOOM level {z}. Should be between {src_dst.minzoom} and {src_dst.maxzoom}",
Expand Down

0 comments on commit b68c0c5

Please sign in to comment.