diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index bee2c6f..e3276d9 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -56,19 +56,18 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install a specific version of uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v6 with: - enable-cache: true - version: "0.5.x" + version: "latest" - name: uv sync working-directory: python - run: uv sync --no-install-package geoindex-rs + run: uv sync --no-install-package async-tiff - name: maturin venv Build working-directory: python run: uv run --no-project maturin develop - # - name: Run pytest - # working-directory: python - # run: uv run --no-project pytest + - name: Run pytest + working-directory: python + run: uv run --no-project pytest --verbose diff --git a/python/pyproject.toml b/python/pyproject.toml index e7a225e..9a5a30a 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -33,7 +33,12 @@ dev-dependencies = [ "numpy>=1", "obstore>=0.5.1", "pip>=24.2", - "pytest-asyncio>=0.24.0", + "pytest-asyncio>=0.26.0", "pytest>=8.3.3", "ruff>=0.8.4", ] + +[tool.pytest.ini_options] +addopts = "--color=yes" +asyncio_default_fixture_loop_scope="function" +asyncio_mode = "auto" diff --git a/python/tests/test_cog.py b/python/tests/test_cog.py index 577a0bb..5aa7758 100644 --- a/python/tests/test_cog.py +++ b/python/tests/test_cog.py @@ -1,27 +1,25 @@ -import async_tiff -from time import time -from async_tiff import TIFF +from async_tiff import TIFF, enums from async_tiff.store import S3Store -store = S3Store("sentinel-cogs", region="us-west-2", skip_signature=True) -path = "sentinel-s2-l2a-cogs/12/S/UF/2022/6/S2B_12SUF_20220609_0_L2A/B04.tif" -tiff = await TIFF.open(path, store=store, prefetch=32768) +async def test_cog_s3(): + """ + Ensure that TIFF.open can open a Sentinel-2 Cloud-Optimized GeoTIFF file from an + s3 bucket, read IFDs and GeoKeyDirectory metadata. + """ + path = "sentinel-s2-l2a-cogs/12/S/UF/2022/6/S2B_12SUF_20220609_0_L2A/B04.tif" + store = S3Store("sentinel-cogs", region="us-west-2", skip_signature=True) + tiff = await TIFF.open(path=path, store=store, prefetch=32768) -start = time() -tiff = await TIFF.open(path, store=store, prefetch=32768) -end = time() -end - start + ifds = tiff.ifds + assert len(ifds) == 5 -ifds = tiff.ifds -ifd = ifds[0] -ifd.compression -ifd.tile_height -ifd.tile_width -ifd.photometric_interpretation -gkd = ifd.geo_key_directory -gkd.citation -gkd.projected_type -gkd.citation + ifd = ifds[0] + assert ifd.compression == enums.CompressionMethod.Deflate + assert ifd.tile_height == 1024 + assert ifd.tile_width == 1024 + assert ifd.photometric_interpretation == enums.PhotometricInterpretation.BlackIsZero -dir(gkd) + gkd = ifd.geo_key_directory + assert gkd.citation == "WGS 84 / UTM zone 12N" + assert gkd.projected_type == 32612 diff --git a/python/uv.lock b/python/uv.lock index f869127..03de838 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -1,4 +1,5 @@ version = 1 +revision = 1 requires-python = ">=3.9" resolution-markers = [ "python_full_version >= '3.10'", @@ -68,7 +69,7 @@ dev = [ { name = "obstore", specifier = ">=0.5.1" }, { name = "pip", specifier = ">=24.2" }, { name = "pytest", specifier = ">=8.3.3" }, - { name = "pytest-asyncio", specifier = ">=0.24.0" }, + { name = "pytest-asyncio", specifier = ">=0.26.0" }, { name = "ruff", specifier = ">=0.8.4" }, ] @@ -1327,14 +1328,15 @@ wheels = [ [[package]] name = "pytest-asyncio" -version = "0.25.3" +version = "0.26.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pytest" }, + { name = "typing-extensions", marker = "python_full_version < '3.10'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/f2/a8/ecbc8ede70921dd2f544ab1cadd3ff3bf842af27f87bbdea774c7baa1d38/pytest_asyncio-0.25.3.tar.gz", hash = "sha256:fc1da2cf9f125ada7e710b4ddad05518d4cee187ae9412e9ac9271003497f07a", size = 54239 } +sdist = { url = "https://files.pythonhosted.org/packages/8e/c4/453c52c659521066969523e87d85d54139bbd17b78f09532fb8eb8cdb58e/pytest_asyncio-0.26.0.tar.gz", hash = "sha256:c4df2a697648241ff39e7f0e4a73050b03f123f760673956cf0d72a4990e312f", size = 54156 } wheels = [ - { url = "https://files.pythonhosted.org/packages/67/17/3493c5624e48fd97156ebaec380dcaafee9506d7e2c46218ceebbb57d7de/pytest_asyncio-0.25.3-py3-none-any.whl", hash = "sha256:9e89518e0f9bd08928f97a3482fdc4e244df17529460bc038291ccaf8f85c7c3", size = 19467 }, + { url = "https://files.pythonhosted.org/packages/20/7f/338843f449ace853647ace35870874f69a764d251872ed1b4de9f234822c/pytest_asyncio-0.26.0-py3-none-any.whl", hash = "sha256:7b51ed894f4fbea1340262bdae5135797ebbe21d8638978e35d31c6d19f72fb0", size = 19694 }, ] [[package]]