diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 1320893a..6f3aaae7 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +## [0.1.2] - 2024-09-22 + +### Changed + +- Return the item count from `search_to` + ## [0.1.1] - 2024-09-21 ### Added @@ -39,7 +45,8 @@ Non-functional release to fix releasing from Github actions. Initial release. -[Unreleased]: https://github.com/stac-utils/stac-rs/compare/python-v0.1.1...main +[Unreleased]: https://github.com/stac-utils/stac-rs/compare/python-v0.1.2...main +[0.1.2]: https://github.com/stac-utils/stac-rs/compare/python-v0.1.1...python-v0.1.2 [0.1.1]: https://github.com/stac-utils/stac-rs/compare/python-v0.1.0...python-v0.1.1 [0.1.0]: https://github.com/stac-utils/stac-rs/compare/python-v0.0.3...python-v0.1.0 [0.0.3]: https://github.com/stac-utils/stac-rs/compare/python-v0.0.2...python-v0.0.3 diff --git a/python/Cargo.toml b/python/Cargo.toml index 4bac220d..f7e44ba3 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -4,7 +4,7 @@ description = "Python bindings for stac-rs" license = "MIT OR Apache-2.0" repository = "https://github.com/stac-utils/stac-rs" homepage = "https://github.com/stac-utils/stac-rs" -version = "0.1.1" +version = "0.1.2" edition = "2021" publish = false diff --git a/python/python/stacrs/stacrs.pyi b/python/python/stacrs/stacrs.pyi index dd7d9257..36b32073 100644 --- a/python/python/stacrs/stacrs.pyi +++ b/python/python/stacrs/stacrs.pyi @@ -42,7 +42,7 @@ def search_to( query: Optional[dict[str, Any]] = None, format: Optional[str] = None, options: Optional[list[Tuple[str, str]]] = None, -) -> None: ... +) -> int: ... def validate_href(href: str) -> None: ... def validate(value: dict[str, Any]) -> None: ... def write( diff --git a/python/src/search.rs b/python/src/search.rs index 6ef31f56..4e016788 100644 --- a/python/src/search.rs +++ b/python/src/search.rs @@ -157,7 +157,7 @@ pub fn search_to( query: Option>, format: Option, options: Option>, -) -> PyResult<()> { +) -> PyResult { let items = search_items( href, intersects, @@ -180,6 +180,7 @@ pub fn search_to( .or_else(|| Format::infer_from_href(&outfile)) .unwrap_or_default(); let item_collection = ItemCollection::from(items); + let count = item_collection.items.len(); Builder::new_current_thread() .build()? .block_on(format.put_opts( @@ -188,7 +189,7 @@ pub fn search_to( options.unwrap_or_default(), )) .map_err(Error::from)?; - Ok(()) + Ok(count) } fn search_items( diff --git a/python/tests/test_search.py b/python/tests/test_search.py index df3631e1..b4d57599 100644 --- a/python/tests/test_search.py +++ b/python/tests/test_search.py @@ -32,7 +32,7 @@ def test_search_to(tmp_path: Path) -> None: def test_search_to_geoparquet(tmp_path: Path) -> None: - stacrs.search_to( + count = stacrs.search_to( str(tmp_path / "out.parquet"), "https://landsatlook.usgs.gov/stac-server", collections="landsat-c2l2-sr", @@ -40,6 +40,7 @@ def test_search_to_geoparquet(tmp_path: Path) -> None: sortby="-properties.datetime", max_items=1, ) + assert count == 1 table = pyarrow.parquet.read_table(tmp_path / "out.parquet") items = list(stac_geoparquet.arrow.stac_table_to_items(table)) assert len(items) == 1