Skip to content

Commit

Permalink
Handle kerchunk [path] with no offset/length
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Jul 15, 2024
1 parent 63cb722 commit 606a465
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions virtualizarr/manifests/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numpy as np
from pydantic import BaseModel, ConfigDict
from upath import UPath

from virtualizarr.types import ChunkKey

Expand Down Expand Up @@ -42,9 +43,14 @@ def __repr__(self) -> str:

@classmethod
def from_kerchunk(
cls, path_and_byte_range_info: tuple[str, int, int]
cls, path_and_byte_range_info: tuple[str] | tuple[str, int, int]
) -> "ChunkEntry":
path, offset, length = path_and_byte_range_info
if len(path_and_byte_range_info) == 1:
path = path_and_byte_range_info[0]
offset = 0
length = UPath(path).stat().st_size
else:
path, offset, length = path_and_byte_range_info
return ChunkEntry(path=path, offset=offset, length=length)

def to_kerchunk(self) -> tuple[str, int, int]:
Expand Down

0 comments on commit 606a465

Please sign in to comment.