|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from collections.abc import AsyncGenerator |
4 | | -from contextlib import asynccontextmanager |
5 | | -from typing import Any |
| 3 | +from .geoparquet import geoparquet_writer |
| 4 | +from .rustac import * |
6 | 5 |
|
7 | | -from obstore.store import ObjectStore |
8 | | - |
9 | | -from . import store |
10 | | -from .rustac import * # noqa: F403 |
11 | | - |
12 | | - |
13 | | -@asynccontextmanager |
14 | | -async def geoparquet_writer( |
15 | | - items: list[dict[str, Any]], |
16 | | - path: str, |
17 | | - drop_invalid_attributes: bool = True, |
18 | | - store: store.Store | ObjectStore | None = None, |
19 | | -) -> AsyncGenerator[GeoparquetWriter]: # noqa: F405 |
20 | | - """Open a geoparquet writer in a context manager. |
21 | | -
|
22 | | - The items provided to the initial call will be used to build the geoparquet |
23 | | - schema. All subsequent items must have the same schema. |
24 | | -
|
25 | | - The underlying parquet writer will group batches of items into row groups |
26 | | - based upon it's default configuration; the row groups are _not_ determined |
27 | | - by the size of the item lists passed to the writer. |
28 | | -
|
29 | | - Args: |
30 | | - items: The STAC items |
31 | | - path: The path for the stac-geoparquet file |
32 | | - drop_invalid_attributes: If true, invalid attributes (e.g. an `id` in |
33 | | - the `properties` field) will be dropped. If false, raise an error if |
34 | | - an invalid attribute is encountered. |
35 | | - store: The optional object store to use for writing the geoparquet file. |
36 | | -
|
37 | | - Examples: |
38 | | -
|
39 | | - >>> async with geoparquet_writer(item_batches[0], "out.parquet") as w: |
40 | | - ... for items in item_batches[1:]: |
41 | | - ... await w.write(items) |
42 | | - ... |
43 | | - >>> |
44 | | - """ |
45 | | - writer = await GeoparquetWriter.open(items, path, drop_invalid_attributes, store) # noqa: F405 |
46 | | - yield writer |
47 | | - await writer.finish() |
48 | | - |
49 | | - |
50 | | -__doc__ = rustac.__doc__ # noqa: F405 |
51 | | -if hasattr(rustac, "__all__"): # noqa: F405 |
52 | | - __all__ = rustac.__all__ # noqa: F405 |
53 | | -else: |
54 | | - __all__ = [] |
55 | | - |
56 | | -__all__.append("store") |
| 6 | +__doc__ = rustac.__doc__ |
| 7 | +__all__ = rustac.__all__ + ["geoparquet_writer"] # pyright: ignore[reportUnsupportedDunderAll, reportAttributeAccessIssue] |
0 commit comments