From bfce9aca747502e2257decd0138df06d0d5d8b2d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 1 May 2025 15:25:19 +1200 Subject: [PATCH 01/12] Set asyncio_mode="auto" in pytest.ini config Xref https://pytest-asyncio.readthedocs.io/en/latest/reference/configuration.html#asyncio-mode --- python/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/pyproject.toml b/python/pyproject.toml index e7a225e..8337296 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -37,3 +37,6 @@ dev-dependencies = [ "pytest>=8.3.3", "ruff>=0.8.4", ] + +[tool.pytest.ini_options] +asyncio_mode = "auto" From 695bc5f26279c395b44c097cbabc06d2221f74a5 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 1 May 2025 15:37:44 +1200 Subject: [PATCH 02/12] Refactor contents of test_cog.py into a proper unit test Put everything in an `async def test_cog_s3` function, with assertions checking different metadata attributes. --- python/tests/test_cog.py | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/python/tests/test_cog.py b/python/tests/test_cog.py index 577a0bb..ea36ff2 100644 --- a/python/tests/test_cog.py +++ b/python/tests/test_cog.py @@ -1,27 +1,31 @@ -import async_tiff from time import time -from async_tiff import TIFF + +from async_tiff import enums, TIFF, ImageFileDirectory 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. + """ + 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" + + start = time() + tiff = await TIFF.open(path=path, store=store, prefetch=32768) + end = time() + assert end - start < 5 # take less than 5 seconds to open -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 From bfb3a43851910c446ace0a589529b50f5821657d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 1 May 2025 15:38:18 +1200 Subject: [PATCH 03/12] Uncomment `uv run pytest` in .github/workflows/test-python.yml --- .github/workflows/test-python.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index bee2c6f..9eb6b2c 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -67,8 +67,8 @@ jobs: - name: maturin venv Build working-directory: python - run: uv run --no-project maturin develop + run: uv run maturin develop - # - name: Run pytest - # working-directory: python - # run: uv run --no-project pytest + - name: Run pytest + working-directory: python + run: uv run pytest --verbose From d0f98acf037fed494450eb45b8a12794e1e9ae4e Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 1 May 2025 16:02:55 +1200 Subject: [PATCH 04/12] Add `--color=yes`flag to force GitHub Actions logs to have color Xref https://github.com/pytest-dev/pytest/issues/7443 --- python/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pyproject.toml b/python/pyproject.toml index 8337296..a2757f7 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -39,4 +39,5 @@ dev-dependencies = [ ] [tool.pytest.ini_options] +addopts = "--color=yes" asyncio_mode = "auto" From b08fe516945fb73fedbe4ec8008977a1a05b5265 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Thu, 1 May 2025 16:31:37 +1200 Subject: [PATCH 05/12] Ruff format --- python/tests/test_cog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tests/test_cog.py b/python/tests/test_cog.py index ea36ff2..272b6bc 100644 --- a/python/tests/test_cog.py +++ b/python/tests/test_cog.py @@ -1,6 +1,6 @@ from time import time -from async_tiff import enums, TIFF, ImageFileDirectory +from async_tiff import TIFF, enums from async_tiff.store import S3Store From 28973b91a693c7b2fb6bfc9ba1d82020f5927e03 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 2 May 2025 08:09:17 +1200 Subject: [PATCH 06/12] Remove timing assertions --- python/tests/test_cog.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/python/tests/test_cog.py b/python/tests/test_cog.py index 272b6bc..5aa7758 100644 --- a/python/tests/test_cog.py +++ b/python/tests/test_cog.py @@ -1,5 +1,3 @@ -from time import time - from async_tiff import TIFF, enums from async_tiff.store import S3Store @@ -9,13 +7,9 @@ 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. """ - 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" - - start = time() + store = S3Store("sentinel-cogs", region="us-west-2", skip_signature=True) tiff = await TIFF.open(path=path, store=store, prefetch=32768) - end = time() - assert end - start < 5 # take less than 5 seconds to open ifds = tiff.ifds assert len(ifds) == 5 From 12b230f57c67b7bb02105e3cc235d194c7c6d647 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 2 May 2025 08:49:57 +1200 Subject: [PATCH 07/12] Bump astral-sh/setup-uv from 3 to 6 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 3 to 6. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v3...v6) --- .github/workflows/test-python.yml | 5 ++--- python/uv.lock | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 9eb6b2c..62b0afe 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -56,10 +56,9 @@ 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 diff --git a/python/uv.lock b/python/uv.lock index f869127..6c807aa 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'", From 638d6029b03fe15262386ceb98015514ed8579d8 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 2 May 2025 12:40:44 +1200 Subject: [PATCH 08/12] Remove `uv sync` part --- .github/workflows/test-python.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 62b0afe..3986024 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -60,10 +60,6 @@ jobs: with: version: "latest" - - name: uv sync - working-directory: python - run: uv sync --no-install-package geoindex-rs - - name: maturin venv Build working-directory: python run: uv run maturin develop From 3be22b7661c1908311bd2d98abe98510f7829aa6 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 2 May 2025 12:52:02 +1200 Subject: [PATCH 09/12] Bump pytest-asyncio from 0.24.0 to 0.26.0 Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.24.0 to 0.26.0. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.24.0...v0.26.0) Also set asyncio_default_fixture_loop_scope="function" following https://github.com/pytest-dev/pytest-asyncio/issues/924#issuecomment-2326877541 --- python/pyproject.toml | 3 ++- python/uv.lock | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index a2757f7..9a5a30a 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -33,11 +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/uv.lock b/python/uv.lock index 6c807aa..03de838 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -69,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" }, ] @@ -1328,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]] From ca3104827a43fc89692ad2ea10045a106cbcf83f Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 5 May 2025 09:17:23 +1200 Subject: [PATCH 10/12] Revert "Remove `uv sync` part" This reverts commit 638d6029b03fe15262386ceb98015514ed8579d8. --- .github/workflows/test-python.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 3986024..62b0afe 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -60,6 +60,10 @@ jobs: with: version: "latest" + - name: uv sync + working-directory: python + run: uv sync --no-install-package geoindex-rs + - name: maturin venv Build working-directory: python run: uv run maturin develop From 773fad81169f45605babb9517ea3f6cf37817fe8 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 5 May 2025 09:18:20 +1200 Subject: [PATCH 11/12] Typo geoindex-rs -> async-tiff --- .github/workflows/test-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 62b0afe..c78f98e 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -62,7 +62,7 @@ jobs: - 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 From aa213688c943406f8a2d9eaa6b4fcd7347857210 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 5 May 2025 09:20:34 +1200 Subject: [PATCH 12/12] Add back `--no-project` flag to `uv run` commands Partially undo bfb3a43851910c446ace0a589529b50f5821657d --- .github/workflows/test-python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index c78f98e..e3276d9 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -66,8 +66,8 @@ jobs: - name: maturin venv Build working-directory: python - run: uv run maturin develop + run: uv run --no-project maturin develop - name: Run pytest working-directory: python - run: uv run pytest --verbose + run: uv run --no-project pytest --verbose