diff --git a/pixi.lock b/pixi.lock index c85c41a..7da5669 100644 --- a/pixi.lock +++ b/pixi.lock @@ -861,6 +861,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/flake8-7.3.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/fonttools-4.61.1-pyh7db6752_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/fqdn-1.5.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/fsspec-2026.9.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda @@ -987,6 +988,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/flake8-7.3.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/fonttools-4.61.1-pyh7db6752_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/fqdn-1.5.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/fsspec-2026.9.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda @@ -1224,6 +1226,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/flake8-7.3.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/fonttools-4.61.1-pyh7db6752_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/fqdn-1.5.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/fsspec-2026.9.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda @@ -3470,6 +3473,18 @@ packages: - pkg:pypi/fqdn?source=hash-mapping size: 16705 timestamp: 1733327494780 +- conda: https://conda.anaconda.org/conda-forge/noarch/fsspec-2026.9.0-pyhd8ed1ab_0.conda + sha256: 7d17272012e7479ba58f8a72b522d3e88e6837a04a111a278ff417aa82364255 + md5: 42de5cd170647599a84f468a42fabb89 + depends: + - python >=3.11 + license: BSD-3-Clause + license_family: BSD + purls: + - pkg:pypi/fsspec?source=compressed-mapping + run_exports: {} + size: 163722 + timestamp: 1790256848815 - conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhcf101f3_1.conda sha256: 96cac6573fd35ae151f4d6979bab6fbc90cb6b1fb99054ba19eb075da9822fcb md5: b8993c19b0c32a2f7b66cbb58ca27069 diff --git a/pyproject.toml b/pyproject.toml index d9e82a4..3623603 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,5 +138,6 @@ shapely = "*" [tool.pixi.feature.dev.dependencies] flake8 = "*" +fsspec = "*" pytest = ">=4.6" pytest-cov = "*" diff --git a/tests/test_cloud.py b/tests/test_cloud.py index 7de944e..04941e1 100644 --- a/tests/test_cloud.py +++ b/tests/test_cloud.py @@ -8,6 +8,7 @@ import os import shutil import numpy as np +import pytest import pointCollection as pc from pointCollection.scripts.query_ATL11_cloud import ( read_ATL11_granule_cloud, read_ATL11_granule_cloud_items) @@ -106,9 +107,18 @@ def test_read_ATL11_granule_cloud_merges_items(tmp_path): assert merged.size == sum(Di.size for Di in items) +def test_read_ATL11_granule_cloud_items_missing_index_raises(tmp_path): + """by default, a missing index is a staging error""" + with pytest.raises(FileNotFoundError, match='missing geoIndex'): + read_ATL11_granule_cloud_items( + 'not-a-real-granule.h5', str(tmp_path / 'no_such_index.h5'), [-1, 1], [-1, 1]) + + def test_read_ATL11_granule_cloud_items_missing_index_returns_none(tmp_path): - items = read_ATL11_granule_cloud_items( - 'not-a-real-granule.h5', str(tmp_path / 'no_such_index.h5'), [-1, 1], [-1, 1]) + with pytest.warns(UserWarning, match='missing geoIndex'): + items = read_ATL11_granule_cloud_items( + 'not-a-real-granule.h5', str(tmp_path / 'no_such_index.h5'), [-1, 1], [-1, 1], + missing_index='skip') assert items is None diff --git a/tests/test_cloud_paths.py b/tests/test_cloud_paths.py index a7188b5..09f9f6e 100644 --- a/tests/test_cloud_paths.py +++ b/tests/test_cloud_paths.py @@ -200,14 +200,23 @@ def test_remote_index_is_not_reported_missing(tmp_path): assert items is not None and len(items) > 0 +def test_missing_remote_index_raises(tmp_path): + """by default, a remote index that really is absent is a staging error""" + index_fs = FakeS3FS({}) + with pytest.raises(FileNotFoundError, match='missing geoIndex'): + read_ATL11_granule_cloud_items( + 'ATL11_044110_0331_007_04.h5', 's3://bucket/no_such_index.h5', + [-1, 1], [-1, 1], index_fs=index_fs) + + def test_missing_remote_index_still_skips(tmp_path): - """a remote index that really is absent must still warn and skip""" + """with missing_index='skip', an absent remote index must warn and skip""" index_fs = FakeS3FS({}) import warnings with warnings.catch_warnings(record=True) as caught: warnings.simplefilter('always') items = read_ATL11_granule_cloud_items( 'ATL11_044110_0331_007_04.h5', 's3://bucket/no_such_index.h5', - [-1, 1], [-1, 1], index_fs=index_fs) + [-1, 1], [-1, 1], index_fs=index_fs, missing_index='skip') assert items is None assert any('missing geoIndex' in str(w.message) for w in caught)