Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
paraseba committed Feb 20, 2025
1 parent 2b8afda commit 547baf0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
37 changes: 31 additions & 6 deletions icechunk-python/python/icechunk/_icechunk_python.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,37 @@ class VirtualChunkContainer:
"""

class VirtualChunkSpec:
index: list[int]
location: str
offset: int
length: int
etag_checksum: str | None
last_updated_at_checksum: datetime.datetime | None
"""The specification for a virtual chunk reference."""
@property
def index(self) -> list[int]:
"""The chunk index, in chunk coordinates space"""
...
@property
def location(self) -> str:
"""The URL to the virtual chunk data, something like 's3://bucket/foo.nc'"""
...
@property
def offset(self) -> int:
"""The chunk offset within the pointed object, in bytes"""
...
@property
def length(self) -> int:
"""The length of the chunk in bytes"""
...
@property
def etag_checksum(self) -> str | None:
"""Optional object store e-tag for the containing object.
Icechunk will refuse to serve data from this chunk if the etag has changed.
"""
...
@property
def last_updated_at_checksum(self) -> datetime.datetime | None:
"""Optional timestamp for the containing object.
Icechunk will refuse to serve data from this chunk if it has been modified in object store after this time.
"""
...

def __init__(
self,
Expand Down
19 changes: 19 additions & 0 deletions icechunk-python/python/icechunk/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,25 @@ def set_virtual_refs(
*,
validate_containers: bool = False,
) -> list[tuple[int, ...]] | None:
"""Store multiple virtual references for the same array.
Parameters
----------
array_path : str
The path to the array inside the Zarr store. Example: "/groupA/groupB/outputs/my-array"
chunks : list[VirtualChunkSpec],
The list of virtula chunks to add
validate_containers: bool
If set to true, ignore virtual references for locations that don't match any existing virtual chunk container
Returns
-------
list[tuple[int, ...]] | None
If all virtual references where successfully updated, it returns None.
If there were validation errors, it returns the chunk indices of all failed references.
"""
return self._store.set_virtual_refs(array_path, chunks, validate_containers)

async def delete(self, key: str) -> None:
Expand Down

0 comments on commit 547baf0

Please sign in to comment.