Skip to content

Commit 32eba16

Browse files
authored
Update Python docstrings (#63)
1 parent eba4e53 commit 32eba16

File tree

17 files changed

+117
-28
lines changed

17 files changed

+117
-28
lines changed

python/_obstore

Submodule _obstore updated 112 files

python/docs/api/decoder.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Decoder
2+
3+
::: async_tiff.Decoder
4+
::: async_tiff.DecoderRegistry

python/docs/api/geo.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Geospatial tags
2+
3+
::: async_tiff.GeoKeyDirectory
4+
options:
5+
show_if_no_docstring: true

python/docs/api/ifd.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# IFD
2+
3+
::: async_tiff.ImageFileDirectory
4+
options:
5+
show_if_no_docstring: true

python/docs/api/store/aws.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# AWS S3
22

33
::: async_tiff.store.S3Store
4-
::: async_tiff.store.S3ConfigInput
5-
options:
6-
show_if_no_docstring: true
74
::: async_tiff.store.S3Config
85
options:
96
show_if_no_docstring: true

python/docs/api/store/azure.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
::: async_tiff.store.AzureStore
44
::: async_tiff.store.AzureAccessKey
5-
::: async_tiff.store.AzureConfigInput
6-
options:
7-
show_if_no_docstring: true
85
::: async_tiff.store.AzureConfig
96
options:
107
show_if_no_docstring: true

python/docs/api/store/gcs.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Google Cloud Storage
22

33
::: async_tiff.store.GCSStore
4-
::: async_tiff.store.GCSConfigInput
5-
options:
6-
show_if_no_docstring: true
74
::: async_tiff.store.GCSConfig
85
options:
96
show_if_no_docstring: true

python/docs/api/thread-pool.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Thread Pool
2+
3+
::: async_tiff.ThreadPool

python/docs/api/tiff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# TIFF
2+
3+
::: async_tiff.TIFF
4+
options:
5+
show_if_no_docstring: true

python/docs/api/tile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Tile
2+
3+
::: async_tiff.Tile
4+
options:
5+
show_if_no_docstring: true

python/mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ extra:
2323
nav:
2424
- "index.md"
2525
- API Reference:
26+
- api/tiff.md
27+
- api/ifd.md
28+
- api/tile.md
29+
- api/geo.md
30+
- api/decoder.md
31+
- api/thread-pool.md
2632
- async-tiff.store:
2733
- api/store/index.md
2834
- api/store/aws.md

python/python/async_tiff/_decoder.pyi

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,26 @@ from collections.abc import Buffer
44
from .enums import CompressionMethod
55

66
class Decoder(Protocol):
7+
"""A custom Python-provided decompression algorithm."""
78
# In the future, we could pass in photometric interpretation and jpeg tables as
89
# well.
910
@staticmethod
10-
def __call__(buffer: Buffer) -> Buffer: ...
11+
def __call__(buffer: Buffer) -> Buffer:
12+
"""A callback to decode compressed data."""
1113

1214
class DecoderRegistry:
15+
"""A registry holding multiple decoder methods."""
1316
def __init__(
14-
self, decoders: dict[CompressionMethod | int, Decoder] | None = None
15-
) -> None: ...
17+
self, custom_decoders: dict[CompressionMethod | int, Decoder] | None = None
18+
) -> None:
19+
"""Construct a new decoder registry.
20+
21+
By default, pure-Rust decoders will be used for any recognized and supported
22+
compression types. Only the supplied decoders will override Rust-native
23+
decoders.
24+
25+
Args:
26+
custom_decoders: any custom decoder methods to use. This will be applied
27+
_after_ (and override) any default provided Rust decoders. Defaults to
28+
None.
29+
"""
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
class ThreadPool:
2-
def __init__(self, num_threads: int) -> None: ...
2+
"""A Rust-managed thread pool."""
3+
def __init__(self, num_threads: int) -> None:
4+
"""Construct a new ThreadPool with the given number of threads."""

python/python/async_tiff/_tiff.pyi

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,43 @@ class TIFF:
1111
*,
1212
store: obstore.store.ObjectStore | ObjectStore,
1313
prefetch: int | None = 16384,
14-
) -> TIFF: ...
14+
) -> TIFF:
15+
"""Open a new TIFF.
16+
17+
Args:
18+
path: The path within the store to read from.
19+
store: The backend to use for data fetching.
20+
prefetch: The number of initial bytes to read up front. Defaults to 16384.
21+
22+
Returns:
23+
A TIFF instance.
24+
"""
1525
@property
16-
def ifds(self) -> list[ImageFileDirectory]: ...
17-
async def fetch_tile(self, x: int, y: int, z: int) -> Tile: ...
18-
async def fetch_tiles(self, x: list[int], y: list[int], z: int) -> list[Tile]: ...
26+
def ifds(self) -> list[ImageFileDirectory]:
27+
"""Access the underlying IFDs of this TIFF.
28+
29+
Each ImageFileDirectory (IFD) represents one of the internal "sub images" of
30+
this file.
31+
"""
32+
async def fetch_tile(self, x: int, y: int, z: int) -> Tile:
33+
"""Fetch a single tile.
34+
35+
Args:
36+
x: The column index within the ifd to read from.
37+
y: The row index within the ifd to read from.
38+
z: The IFD index to read from.
39+
40+
Returns:
41+
Tile response.
42+
"""
43+
async def fetch_tiles(self, x: list[int], y: list[int], z: int) -> list[Tile]:
44+
"""Fetch multiple tiles concurrently.
45+
46+
Args:
47+
x: The column indexes within the ifd to read from.
48+
y: The row indexes within the ifd to read from.
49+
z: The IFD index to read from.
50+
51+
Returns:
52+
Tile responses.
53+
"""

python/python/async_tiff/_tile.pyi

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,31 @@ from ._decoder import DecoderRegistry
55
from ._thread_pool import ThreadPool
66

77
class Tile:
8+
"""A representation of a TIFF image tile."""
89
@property
9-
def x(self) -> int: ...
10+
def x(self) -> int:
11+
"""The column index this tile represents."""
1012
@property
11-
def y(self) -> int: ...
13+
def y(self) -> int:
14+
"""The row index this tile represents."""
1215
@property
13-
def compressed_bytes(self) -> Buffer: ...
16+
def compressed_bytes(self) -> Buffer:
17+
"""The compressed bytes underlying this tile."""
1418
@property
15-
def compression_method(self) -> CompressionMethod: ...
19+
def compression_method(self) -> CompressionMethod | int:
20+
"""The compression method used by this tile."""
1621
async def decode(
1722
self,
1823
*,
1924
decoder_registry: DecoderRegistry | None = None,
2025
pool: ThreadPool | None = None,
21-
) -> Buffer: ...
26+
) -> Buffer:
27+
"""Decode this tile's data.
28+
29+
Keyword Args:
30+
decoder_registry: the decoders to use for decompression. Defaults to None.
31+
pool: the thread pool on which to run decompression. Defaults to None.
32+
33+
Returns:
34+
Decoded tile data as a buffer.
35+
"""

python/python/async_tiff/store

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../_obstore/obstore/python/obstore/store
1+
../../_obstore/obstore/python/obstore/_store

python/src/decoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub(crate) struct PyDecoderRegistry(Arc<DecoderRegistry>);
2929
#[pymethods]
3030
impl PyDecoderRegistry {
3131
#[new]
32-
#[pyo3(signature = (decoders = None))]
33-
pub(crate) fn new(decoders: Option<HashMap<PyCompressionMethod, PyDecoder>>) -> Self {
32+
#[pyo3(signature = (custom_decoders = None))]
33+
pub(crate) fn new(custom_decoders: Option<HashMap<PyCompressionMethod, PyDecoder>>) -> Self {
3434
let mut decoder_registry = DecoderRegistry::default();
35-
if let Some(decoders) = decoders {
36-
for (compression, decoder) in decoders.into_iter() {
35+
if let Some(custom_decoders) = custom_decoders {
36+
for (compression, decoder) in custom_decoders.into_iter() {
3737
decoder_registry
3838
.as_mut()
3939
.insert(compression.into(), Box::new(decoder));

0 commit comments

Comments
 (0)