Skip to content

Commit d968382

Browse files
authored
fix: clean up docs, remove migrate_href (#78)
1 parent 5eff9c4 commit d968382

File tree

5 files changed

+51
-89
lines changed

5 files changed

+51
-89
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
99
### Fixed
1010

1111
- Swallow broken pipe errors ([#73](https://github.com/stac-utils/stacrs/pull/73))
12+
- Clean up docs ([#78](https://github.com/stac-utils/stacrs/pull/78))
13+
14+
### Removed
15+
16+
- `migrate_href` ([#78](https://github.com/stac-utils/stacrs/pull/78))
1217

1318
## [0.5.9] - 2025-03-03
1419

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ fn stacrs(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
2828
m.add_function(wrap_pyfunction!(arrow::to_arrow, m)?)?;
2929
m.add_function(wrap_pyfunction!(cli::main, m)?)?;
3030
m.add_function(wrap_pyfunction!(migrate::migrate, m)?)?;
31-
m.add_function(wrap_pyfunction!(migrate::migrate_href, m)?)?;
3231
m.add_function(wrap_pyfunction!(read::read, m)?)?;
3332
m.add_function(wrap_pyfunction!(search::search, m)?)?;
3433
m.add_function(wrap_pyfunction!(search::search_to, m)?)?;

src/migrate.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,3 @@ pub fn migrate<'py>(
1818
let value = value.extract()?;
1919
Ok(value)
2020
}
21-
22-
#[pyfunction]
23-
#[pyo3(signature = (href, version=None))]
24-
pub fn migrate_href<'py>(
25-
py: Python<'py>,
26-
href: &str,
27-
version: Option<&str>,
28-
) -> Result<Bound<'py, PyDict>> {
29-
let value: Value = stac::read(href).map_err(Error::from)?;
30-
let version = version
31-
.map(|version| version.parse().unwrap())
32-
.unwrap_or_default();
33-
let value = value.migrate(&version)?;
34-
let value = pythonize::pythonize(py, &value)?;
35-
let value = value.extract()?;
36-
Ok(value)
37-
}

stacrs.pyi

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, AsyncIterator, Optional, Tuple
1+
from typing import Any, AsyncIterator, Literal, Optional, Tuple
22

33
import arro3.core
44

@@ -142,29 +142,6 @@ class DuckdbClient:
142142
A list of STAC Collections
143143
"""
144144

145-
def migrate_href(href: str, version: Optional[str] = None) -> dict[str, Any]:
146-
"""
147-
Migrates a STAC dictionary at the given href to another version.
148-
149-
Migration can be as simple as updating the `stac_version` attribute, but
150-
sometimes can be more complicated. For example, when migrating to v1.1.0,
151-
[eo:bands and raster:bands should be consolidated to the new bands
152-
structure](https://github.com/radiantearth/stac-spec/releases/tag/v1.1.0-beta.1).
153-
154-
See [the stac-rs
155-
documentation](https://docs.rs/stac/latest/stac/enum.Version.html) for
156-
supported versions.
157-
158-
Args:
159-
href (str): The href to read the STAC object from
160-
version (str | None): The version to migrate to. If not provided, the
161-
value will be migrated to the latest stable version.
162-
163-
Examples:
164-
>>> item = stacrs.migrate_href("examples/simple-item.json", "1.1.0-beta.1")
165-
>>> assert item["stac_version"] == "1.1.0-beta.1"
166-
"""
167-
168145
def migrate(value: dict[str, Any], version: Optional[str] = None) -> dict[str, Any]:
169146
"""
170147
Migrates a STAC dictionary to another version.
@@ -179,8 +156,8 @@ def migrate(value: dict[str, Any], version: Optional[str] = None) -> dict[str, A
179156
supported versions.
180157
181158
Args:
182-
value (dict[str, Any]): The STAC value to migrate
183-
version (str | None): The version to migrate to. If not provided, the
159+
value: The STAC value to migrate
160+
version: The version to migrate to. If not provided, the
184161
value will be migrated to the latest stable version.
185162
186163
Returns:
@@ -270,35 +247,35 @@ async def search(
270247
Searches a STAC API server.
271248
272249
Args:
273-
href (str): The STAC API to search.
274-
intersects (str | dict[str, Any] | GeoInterface | None): Searches items
250+
href: The STAC API to search.
251+
intersects: Searches items
275252
by performing intersection between their geometry and provided GeoJSON
276253
geometry.
277-
ids (list[str] | None): Array of Item ids to return.
278-
collections (list[str] | None): Array of one or more Collection IDs that
254+
ids: Array of Item ids to return.
255+
collections: Array of one or more Collection IDs that
279256
each matching Item must be in.
280-
max_items (int | None): The maximum number of items to iterate through.
281-
limit (int | None): The page size returned from the server. Use
257+
max_items: The maximum number of items to iterate through.
258+
limit: The page size returned from the server. Use
282259
`max_items` to actually limit the number of items returned from this
283260
function.
284-
bbox (list[float] | None): Requested bounding box.
285-
datetime (str | None): Single date+time, or a range (`/` separator),
261+
bbox: Requested bounding box.
262+
datetime: Single date+time, or a range (`/` separator),
286263
formatted to RFC 3339, section 5.6. Use double dots .. for open
287264
date ranges.
288-
include (list[str]] | None): fields to include in the response (see [the
265+
include: fields to include in the response (see [the
289266
extension
290267
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
291268
for more on the semantics).
292-
exclude (list[str]] | None): fields to exclude from the response (see [the
269+
exclude: fields to exclude from the response (see [the
293270
extension
294271
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
295272
for more on the semantics).
296-
sortby (list[str] | None): Fields by which to sort results (use `-field` to sort descending).
297-
filter (str | dict[str, Any] | none): CQL2 filter expression. Strings
273+
sortby: Fields by which to sort results (use `-field` to sort descending).
274+
filter: CQL2 filter expression. Strings
298275
will be interpreted as cql2-text, dictionaries as cql2-json.
299-
query (dict[str, Any] | None): Additional filtering based on properties.
276+
query: Additional filtering based on properties.
300277
It is recommended to use filter instead, if possible.
301-
use_duckdb (bool | None): Query with DuckDB. If None and the href has a
278+
use_duckdb: Query with DuckDB. If None and the href has a
302279
'parquet' or 'geoparquet' extension, will be set to True. Defaults
303280
to None.
304281
kwargs: Additional parameters to pass in to the search.
@@ -340,40 +317,40 @@ async def search_to(
340317
Searches a STAC API server and saves the result to an output file.
341318
342319
Args:
343-
outfile (str): The output href. This can be a local file path, or any
320+
outfile: The output href. This can be a local file path, or any
344321
url scheme supported by [stac::object_store::write].
345-
href (str): The STAC API to search.
346-
intersects (str | dict[str, Any] | GeoInterface | None): Searches items
322+
href: The STAC API to search.
323+
intersects: Searches items
347324
by performing intersection between their geometry and provided GeoJSON
348325
geometry.
349-
ids (list[str] | None): Array of Item ids to return.
350-
collections (list[str] | None): Array of one or more Collection IDs that
326+
ids: Array of Item ids to return.
327+
collections: Array of one or more Collection IDs that
351328
each matching Item must be in.
352-
max_items (int | None): The maximum number of items to iterate through.
353-
limit (int | None): The page size returned from the server. Use
329+
max_items: The maximum number of items to iterate through.
330+
limit: The page size returned from the server. Use
354331
`max_items` to actually limit the number of items returned from this
355332
function.
356-
bbox (list[float] | None): Requested bounding box.
357-
datetime (str | None): Single date+time, or a range ('/' separator),
333+
bbox: Requested bounding box.
334+
datetime: Single date+time, or a range ('/' separator),
358335
formatted to RFC 3339, section 5.6. Use double dots .. for open
359336
date ranges.
360-
include (list[str]] | None): fields to include in the response (see [the
337+
include: fields to include in the response (see [the
361338
extension
362339
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
363340
for more on the semantics).
364-
exclude (list[str]] | None): fields to exclude from the response (see [the
341+
exclude: fields to exclude from the response (see [the
365342
extension
366343
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
367344
for more on the semantics).
368-
sortby (list[str] | None): Fields by which to sort results (use `-field` to sort descending).
369-
filter (str | dict[str, Any] | none): CQL2 filter expression. Strings
345+
sortby: Fields by which to sort results (use `-field` to sort descending).
346+
filter: CQL2 filter expression. Strings
370347
will be interpreted as cql2-text, dictionaries as cql2-json.
371-
query (dict[str, Any] | None): Additional filtering based on properties.
348+
query: Additional filtering based on properties.
372349
It is recommended to use filter instead, if possible.
373-
format (str | None): The output format. If none, will be inferred from
350+
format: The output format. If none, will be inferred from
374351
the outfile extension, and if that fails will fall back to compact JSON.
375-
options (list[tuple[str, str]] | None): Configuration values to pass to the object store backend.
376-
use_duckdb (bool | None): Query with DuckDB. If None and the href has a
352+
options: Configuration values to pass to the object store backend.
353+
use_duckdb: Query with DuckDB. If None and the href has a
377354
'parquet' or 'geoparquet' extension, will be set to True. Defaults
378355
to None.
379356
@@ -417,12 +394,12 @@ async def write(
417394
Writes STAC to a href.
418395
419396
Args:
420-
href (str): The href to write to
421-
value (dict[str, Any] | list[dict[str, Any]]): The value to write. This
397+
href: The href to write to
398+
value: The value to write. This
422399
can be a STAC dictionary or a list of items.
423-
format (str | None): The output format to write. If not provided, will be
400+
format: The output format to write. If not provided, will be
424401
inferred from the href's extension.
425-
options (list[tuple[str, str]] | None): Options for configuring an
402+
options: Options for configuring an
426403
object store, e.g. your AWS credentials.
427404
428405
Returns:
@@ -435,12 +412,18 @@ async def write(
435412
>>> await stacrs.write("items.parquet", items)
436413
"""
437414

438-
def version(name: str | None = None) -> str | None:
415+
def version(
416+
name: Literal["stac"]
417+
| Literal["stac-api"]
418+
| Literal["stac-duckdb"]
419+
| Literal["duckdb"]
420+
| None = None,
421+
) -> str | None:
439422
"""
440423
Returns this package's version, or the version of a upstream.
441424
442425
Args:
443-
name (str | None): The name of the upstream version to return. Valid
426+
name: The name of the upstream version to return. Valid
444427
values are "stac", "stac-api", "stac-duckdb", or "duckdb".
445428
446429
Returns:

tests/test_migrate.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from pathlib import Path
21
from typing import Any
32

43
import stacrs
@@ -7,10 +6,3 @@
76
def test_migrate(item: dict[str, Any]) -> None:
87
item = stacrs.migrate(item, version="1.1.0")
98
assert item["stac_version"] == "1.1.0"
10-
11-
12-
def test_migrate_href(spec_examples: Path) -> None:
13-
item = stacrs.migrate_href(
14-
str(spec_examples / "v1.0.0" / "simple-item.json"), version="1.1.0"
15-
)
16-
assert item["stac_version"] == "1.1.0"

0 commit comments

Comments
 (0)