Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths as URIs #243

Merged
merged 78 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c787da4
validate that paths can be coerced to valid URIs
TomNicholas Oct 2, 2024
b2f3f26
add a test that paths are converted to URIs
TomNicholas Oct 2, 2024
6b15d9e
added test and better error if local path is not absolute
TomNicholas Oct 2, 2024
045cc7a
raise more informative error if path is not absolute
TomNicholas Oct 2, 2024
ddc6b7f
test that empty paths are allowed
TomNicholas Oct 2, 2024
61bf5d6
add failing test for raising on malformed paths
TomNicholas Oct 2, 2024
2896bd8
fix paths in tests
TomNicholas Oct 2, 2024
584adf9
fix more tests
TomNicholas Oct 2, 2024
14b8ca3
remove the file:/// prefix when writing to kerchunk format
TomNicholas Oct 2, 2024
bad0b1b
Merge branch 'main' into paths_as_uris
TomNicholas Oct 19, 2024
739a6bd
absolute paths in recently-added tests
TomNicholas Oct 19, 2024
06f3a4d
absolute paths in recently-added tests
TomNicholas Oct 19, 2024
3d50def
fix one more test
TomNicholas Oct 20, 2024
b37f8d0
Merge branch 'main' into paths_as_uris
TomNicholas Nov 21, 2024
a9bd0a3
stop wrapping specific error in less useful one
TomNicholas Nov 21, 2024
f0bc445
moved remaining kerchunk parsing logic out into translator file
TomNicholas Nov 21, 2024
b224af8
add fs_root parameter to validation fn
TomNicholas Nov 21, 2024
c8d513c
demote ChunkEntry to a TypedDict to separate validation fn
TomNicholas Nov 21, 2024
4ad26cf
actually instead add new constructor method to TypedDict
TomNicholas Nov 21, 2024
7aaaabf
test kerchunk writer with absolute paths
TomNicholas Nov 21, 2024
f66ed79
make kerchunk reader tests pass
TomNicholas Nov 21, 2024
e30ab05
try to implement the fs_root concatenation
TomNicholas Nov 21, 2024
0a4a11d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
98644a7
implementation using cloudpathlib working
TomNicholas Nov 22, 2024
4499cf9
check that fs_root doesn't have a filetype suffix
TomNicholas Nov 22, 2024
d27bdf6
add cloudpathlib to dependencies
TomNicholas Nov 22, 2024
fefab90
allow http paths, and require file suffixes
TomNicholas Nov 22, 2024
927121c
unit tests for path validation
TomNicholas Nov 22, 2024
c561a5d
test whether we can catch malformed paths
TomNicholas Nov 22, 2024
d42ff33
test fs_root
TomNicholas Nov 22, 2024
4b7cd2d
add (unimplemented) validate_entries kwarg to .from_arrays
TomNicholas Nov 23, 2024
0f8b550
add .keys(), .values(), .items()
TomNicholas Nov 23, 2024
8055ba7
test validate_paths during .from_arrays
TomNicholas Nov 23, 2024
f18bf59
ensure validation actually normalizes paths to uris
TomNicholas Nov 23, 2024
96f6360
test .rename_paths correctly validates paths
TomNicholas Nov 23, 2024
b2ed1cd
some release notes
TomNicholas Nov 23, 2024
87fad80
remove now-superfluous coercion to URI in icechunk writer
TomNicholas Nov 23, 2024
1f41d69
added link to icechunk writer performance benchmark
TomNicholas Nov 23, 2024
41ec08f
add reader_kwargs argument to open_virtual_dataset, and pass it down …
TomNicholas Nov 23, 2024
b4cc617
Merge branch 'main' into reader_kwargs
TomNicholas Nov 23, 2024
ffff93e
Merge branch 'main' into paths_as_uris
TomNicholas Nov 23, 2024
26e8950
Merge branch 'main' into paths_as_uris
TomNicholas Nov 23, 2024
19c13ae
ensure relative paths containing .. can be normalized
TomNicholas Nov 23, 2024
6ce7ebd
ensure HDF5 reader always returns absolute URIs
TomNicholas Nov 23, 2024
24b6ea7
ensure HDF reader always returns absolute URIs
TomNicholas Nov 23, 2024
5f0f362
add relative path handling to other kerchunk-based readers
TomNicholas Nov 23, 2024
001f95b
Merge branch 'reader_kwargs' into paths_as_uris
TomNicholas Nov 23, 2024
15ae139
add dmrpp relative path integration test
ayushnag Nov 24, 2024
b3432c6
Merge branch 'main' into paths_as_uris
TomNicholas Nov 26, 2024
ae00ac3
Merge branch 'main' into paths_as_uris
TomNicholas Nov 27, 2024
ddc19c3
Merge branch 'main' into filepath_test_dmrpp
TomNicholas Nov 27, 2024
8353a9b
fix kerchunk relative paths test by pluggin through fs_root kwarg
TomNicholas Nov 27, 2024
251469f
Merge branch 'filepath_test_dmrpp' of https://github.com/ayushnag/Vir…
TomNicholas Nov 27, 2024
0915433
fix dmrpp tests by using absolute filepaths in DMR++ contents
TomNicholas Nov 27, 2024
3ca8f7f
clarify new dmrpp test
TomNicholas Nov 27, 2024
8a90ec7
test handling of relative filepaths to dmrpp files
TomNicholas Nov 27, 2024
4afa34c
group related tests
TomNicholas Nov 27, 2024
da9ee10
removed cloudpathlib from validation code
TomNicholas Dec 1, 2024
3557008
fix bug but restrict fs_root to only handle filesystem paths, not buc…
TomNicholas Dec 2, 2024
ca09096
global list of recognized URI prefixes
TomNicholas Dec 2, 2024
7727d4e
cleanup
TomNicholas Dec 2, 2024
03aa6bc
remove cloudpathlib from dependencies
TomNicholas Dec 2, 2024
4d8ceea
fix/ignore some typing errors
TomNicholas Dec 2, 2024
cd5bec1
rewrite tests to use a new dmrparser_factory
TomNicholas Dec 3, 2024
e521e20
rewrite using global dict of XML strings
TomNicholas Dec 3, 2024
4ff17d0
fix final test by explicitly passing in tmp_path instead of using a f…
TomNicholas Dec 3, 2024
7e0be24
Merge branch 'dmrpp_tests_tmp_path' into paths_as_uris
TomNicholas Dec 3, 2024
bf0bb87
fix bug with not converting Path objects to strings
TomNicholas Dec 3, 2024
25acdf9
Merge branch 'dmrpp_tests_tmp_path' into paths_as_uris
TomNicholas Dec 3, 2024
ac04cef
dmrpp relative paths tests passing
TomNicholas Dec 3, 2024
39bbfaf
fix type hint for filetype kwarg
TomNicholas Dec 3, 2024
9b6906b
Merge branch 'main' into paths_as_uris
TomNicholas Dec 3, 2024
0127f05
user documentation on fs_root
TomNicholas Dec 3, 2024
cd5da5d
change example manifests to use URIs
TomNicholas Dec 3, 2024
df6663f
reminder that rename_paths exists
TomNicholas Dec 3, 2024
be20994
Merge branch 'paths_as_uris' of https://github.com/TomNicholas/Virtua…
TomNicholas Dec 3, 2024
528f722
update release notes
TomNicholas Dec 3, 2024
a8d5a15
remove note about .rename_paths
TomNicholas Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 54 additions & 14 deletions virtualizarr/manifests/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
import json
import re
from collections.abc import Iterable, Iterator
from pathlib import Path
from typing import Any, Callable, Dict, NewType, Tuple, TypedDict, cast

import numpy as np

from virtualizarr.types import ChunkKey

VALID_URI_PREFIXES = {
"s3://",
"gs://",
"azure://",
"r2://",
"cos://",
"minio://",
"file:///",
}
_INTEGER = (
r"([1-9]+\d*|0)" # matches 0 or an unsigned integer that does not begin with zero
)
Expand All @@ -24,18 +34,48 @@ class ChunkDictEntry(TypedDict):
ChunkDict = NewType("ChunkDict", dict[ChunkKey, ChunkDictEntry])


def validate_and_normalize_path_to_uri(path: str) -> str:
"""
Makes all paths into fully-qualified absolute URIs, or raises

See https://en.wikipedia.org/wiki/File_URI_scheme
"""
if not any(path.startswith(prefix) for prefix in VALID_URI_PREFIXES) and path != "":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen people use urlparse (https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse). Not sure if that would be easier to read or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that does look neater, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually handling all these cases is such a PITA that maybe I should just use cloudpathlib.AnyPath

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using cloudpathlib did make this very easy, at the cost of adding a new dependency. Luckily for this use case (string validation) it's only a pure-python standalone dependency.

# assume the path is local
try:
return str(Path(path).as_uri())
except ValueError as e:
if str(e) == "relative path can't be expressed as a file URI":
# problem is that path is relative instead of absolute, so add context to error message that this is forbidden
raise ValueError(
f"paths in the manifest must be absolute, but got {path}"
) from e
TomNicholas marked this conversation as resolved.
Show resolved Hide resolved
else:
# must be some other problem with the path
raise
else:
# (empty paths are allowed through as they represent missing chunks)
# TODO should we do other validation here? e.g. to prevent a malformed path like `file:///directory//filename.nc`?
return path


# TODO combine this with the ChunkDictEntry class?
@dataclasses.dataclass(frozen=True)
class ChunkEntry:
"""
Information for a single chunk in the manifest.

Stored in the form `{"path": "s3://bucket/foo.nc", "offset": 100, "length": 100}`.
Stored in the form `{"path": "s3://bucket//foo.nc", "offset": 100, "length": 100}`.
"""

path: str # TODO stricter typing/validation of possible local / remote paths?
path: str
offset: int
length: int

def __post_init__(self) -> None:
object.__setattr__(self, "path", validate_and_normalize_path_to_uri(self.path))

# TODO kerchunk-specific constructors and translators could just live in the kerchunk module as functions
@classmethod
def from_kerchunk(
cls, path_and_byte_range_info: tuple[str] | tuple[str, int, int]
Expand Down Expand Up @@ -71,10 +111,10 @@ class ChunkManifest:
The manifest can be converted to or from a dictionary which looks like this

{
"0.0.0": {"path": "s3://bucket/foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "s3://bucket/foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "s3://bucket/foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "s3://bucket/foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "s3://bucket//foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "s3://bucket//foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "s3://bucket//foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "s3://bucket//foo.nc", "offset": 400, "length": 100},
}

using the .__init__() and .dict() methods, so users of this class can think of the manifest as if it were a dict mapping zarr chunk keys to byte ranges.
Expand All @@ -99,10 +139,10 @@ def __init__(self, entries: dict, shape: tuple[int, ...] | None = None) -> None:
Chunk keys and byte range information, as a dictionary of the form

{
"0.0.0": {"path": "s3://bucket/foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "s3://bucket/foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "s3://bucket/foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "s3://bucket/foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "s3://bucket//foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "s3://bucket//foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "s3://bucket//foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "s3://bucket//foo.nc", "offset": 400, "length": 100},
}
"""
if shape is None and not entries:
Expand Down Expand Up @@ -250,10 +290,10 @@ def dict(self) -> ChunkDict: # type: ignore[override]
The returned dict will be of the form

{
"0.0.0": {"path": "s3://bucket/foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "s3://bucket/foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "s3://bucket/foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "s3://bucket/foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "s3://bucket//foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "s3://bucket//foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "s3://bucket//foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "s3://bucket//foo.nc", "offset": 400, "length": 100},
}

Entries whose path is an empty string will be interpreted as missing chunks and omitted from the dictionary.
Expand Down
2 changes: 1 addition & 1 deletion virtualizarr/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def create_manifestarray(
def entry_from_chunk_key(ind: tuple[int, ...]) -> dict[str, str | int]:
"""Generate a (somewhat) unique manifest entry from a given chunk key"""
entry = {
"path": f"file.{str(join(ind))}.nc",
"path": f"/foo.{str(join(ind))}.nc",
"offset": offset_from_chunk_key(ind),
"length": length_from_chunk_key(ind),
}
Expand Down
6 changes: 3 additions & 3 deletions virtualizarr/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
def test_kerchunk_roundtrip_in_memory_no_concat():
# Set up example xarray dataset
chunks_dict = {
"0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.1": {"path": "foo.nc", "offset": 200, "length": 100},
"0.0": {"path": "/foo.nc", "offset": 100, "length": 100},
"0.1": {"path": "/foo.nc", "offset": 200, "length": 100},
}
manifest = ChunkManifest(entries=chunks_dict)
marr = ManifestArray(
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_non_dimension_coordinates(self, tmpdir, format):

def test_datetime64_dtype_fill_value(self, tmpdir, format):
chunks_dict = {
"0.0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.0.0": {"path": "/foo.nc", "offset": 100, "length": 100},
}
manifest = ChunkManifest(entries=chunks_dict)
chunks = (1, 1, 1)
Expand Down
76 changes: 38 additions & 38 deletions virtualizarr/tests/test_manifests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ def test_not_equal_chunk_entries(self):
)

chunks_dict1 = {
"0.0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 200, "length": 100},
"0.0.0": {"path": "/oo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "/oo.nc", "offset": 200, "length": 100},
}
manifest1 = ChunkManifest(entries=chunks_dict1)
marr1 = ManifestArray(zarray=zarray, chunkmanifest=manifest1)

chunks_dict2 = {
"0.0.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "/oo.nc", "offset": 300, "length": 100},
"0.0.1": {"path": "/oo.nc", "offset": 400, "length": 100},
}
manifest2 = ChunkManifest(entries=chunks_dict2)
marr2 = ManifestArray(zarray=zarray, chunkmanifest=manifest2)
Expand All @@ -132,9 +132,9 @@ def test_broadcast_existing_axis(self):
assert expanded.shape == (3, 2)
assert expanded.chunks == (1, 2)
assert expanded.manifest.dict() == {
"0.0": {"path": "file.0.0.nc", "offset": 0, "length": 5},
"1.0": {"path": "file.0.0.nc", "offset": 0, "length": 5},
"2.0": {"path": "file.0.0.nc", "offset": 0, "length": 5},
"0.0": {"path": "file:///foo.0.0.nc", "offset": 0, "length": 5},
"1.0": {"path": "file:///foo.0.0.nc", "offset": 0, "length": 5},
"2.0": {"path": "file:///foo.0.0.nc", "offset": 0, "length": 5},
}

def test_broadcast_new_axis(self):
Expand All @@ -143,9 +143,9 @@ def test_broadcast_new_axis(self):
assert expanded.shape == (1, 3)
assert expanded.chunks == (1, 1)
assert expanded.manifest.dict() == {
"0.0": {"path": "file.0.nc", "offset": 0, "length": 5},
"0.1": {"path": "file.1.nc", "offset": 10, "length": 6},
"0.2": {"path": "file.2.nc", "offset": 20, "length": 7},
"0.0": {"path": "file:///foo.0.nc", "offset": 0, "length": 5},
"0.1": {"path": "file:///foo.1.nc", "offset": 10, "length": 6},
"0.2": {"path": "file:///foo.2.nc", "offset": 20, "length": 7},
}

def test_broadcast_scalar(self):
Expand All @@ -154,14 +154,14 @@ def test_broadcast_scalar(self):
assert marr.shape == ()
assert marr.chunks == ()
assert marr.manifest.dict() == {
"0": {"path": "file.0.nc", "offset": 0, "length": 5},
"0": {"path": "file:///foo.0.nc", "offset": 0, "length": 5},
}

expanded = np.broadcast_to(marr, shape=(1,))
assert expanded.shape == (1,)
assert expanded.chunks == (1,)
assert expanded.manifest.dict() == {
"0": {"path": "file.0.nc", "offset": 0, "length": 5},
"0": {"path": "file:///foo.0.nc", "offset": 0, "length": 5},
}

@pytest.mark.parametrize(
Expand Down Expand Up @@ -253,15 +253,15 @@ def test_concat(self):
)

chunks_dict1 = {
"0.0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 200, "length": 100},
"0.0.0": {"path": "/foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "/foo.nc", "offset": 200, "length": 100},
}
manifest1 = ChunkManifest(entries=chunks_dict1)
marr1 = ManifestArray(zarray=zarray, chunkmanifest=manifest1)

chunks_dict2 = {
"0.0.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "/foo.nc", "offset": 300, "length": 100},
"0.0.1": {"path": "/foo.nc", "offset": 400, "length": 100},
}
manifest2 = ChunkManifest(entries=chunks_dict2)
marr2 = ManifestArray(zarray=zarray, chunkmanifest=manifest2)
Expand All @@ -271,10 +271,10 @@ def test_concat(self):
assert result.shape == (5, 2, 20)
assert result.chunks == (5, 1, 10)
assert result.manifest.dict() == {
"0.0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "file:///foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "file:///foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "file:///foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "file:///foo.nc", "offset": 400, "length": 100},
}
assert result.zarray.compressor == zarray.compressor
assert result.zarray.filters == zarray.filters
Expand All @@ -300,8 +300,8 @@ def test_concat_empty(self):
marr1 = ManifestArray(zarray=zarray, chunkmanifest=manifest1)

chunks_dict2 = {
"0.0.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "/foo.nc", "offset": 300, "length": 100},
"0.0.1": {"path": "/foo.nc", "offset": 400, "length": 100},
}
manifest2 = ChunkManifest(entries=chunks_dict2)
marr2 = ManifestArray(zarray=zarray, chunkmanifest=manifest2)
Expand All @@ -311,8 +311,8 @@ def test_concat_empty(self):
assert result.shape == (5, 2, 20)
assert result.chunks == (5, 1, 10)
assert result.manifest.dict() == {
"0.1.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.1.0": {"path": "file:///foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "file:///foo.nc", "offset": 400, "length": 100},
}
assert result.zarray.compressor == zarray.compressor
assert result.zarray.filters == zarray.filters
Expand All @@ -336,15 +336,15 @@ def test_stack(self):
)

chunks_dict1 = {
"0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.1": {"path": "foo.nc", "offset": 200, "length": 100},
"0.0": {"path": "/foo.nc", "offset": 100, "length": 100},
"0.1": {"path": "/foo.nc", "offset": 200, "length": 100},
}
manifest1 = ChunkManifest(entries=chunks_dict1)
marr1 = ManifestArray(zarray=zarray, chunkmanifest=manifest1)

chunks_dict2 = {
"0.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0": {"path": "/foo.nc", "offset": 300, "length": 100},
"0.1": {"path": "/foo.nc", "offset": 400, "length": 100},
}
manifest2 = ChunkManifest(entries=chunks_dict2)
marr2 = ManifestArray(zarray=zarray, chunkmanifest=manifest2)
Expand All @@ -354,10 +354,10 @@ def test_stack(self):
assert result.shape == (5, 2, 20)
assert result.chunks == (5, 1, 10)
assert result.manifest.dict() == {
"0.0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0.0": {"path": "file:///foo.nc", "offset": 100, "length": 100},
"0.0.1": {"path": "file:///foo.nc", "offset": 200, "length": 100},
"0.1.0": {"path": "file:///foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "file:///foo.nc", "offset": 400, "length": 100},
}
assert result.zarray.compressor == zarray.compressor
assert result.zarray.filters == zarray.filters
Expand All @@ -383,8 +383,8 @@ def test_stack_empty(self):
marr1 = ManifestArray(zarray=zarray, chunkmanifest=manifest1)

chunks_dict2 = {
"0.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.0": {"path": "/foo.nc", "offset": 300, "length": 100},
"0.1": {"path": "/foo.nc", "offset": 400, "length": 100},
}
manifest2 = ChunkManifest(entries=chunks_dict2)
marr2 = ManifestArray(zarray=zarray, chunkmanifest=manifest2)
Expand All @@ -394,8 +394,8 @@ def test_stack_empty(self):
assert result.shape == (5, 2, 20)
assert result.chunks == (5, 1, 10)
assert result.manifest.dict() == {
"0.1.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "foo.nc", "offset": 400, "length": 100},
"0.1.0": {"path": "file:///foo.nc", "offset": 300, "length": 100},
"0.1.1": {"path": "file:///foo.nc", "offset": 400, "length": 100},
}
assert result.zarray.compressor == zarray.compressor
assert result.zarray.filters == zarray.filters
Expand All @@ -418,11 +418,11 @@ def test_refuse_combine():
"zarr_format": 2,
}
chunks_dict1 = {
"0.0.0": {"path": "foo.nc", "offset": 100, "length": 100},
"0.0.0": {"path": "/foo.nc", "offset": 100, "length": 100},
}
chunkmanifest1 = ChunkManifest(entries=chunks_dict1)
chunks_dict2 = {
"0.0.0": {"path": "foo.nc", "offset": 300, "length": 100},
"0.0.0": {"path": "/foo.nc", "offset": 300, "length": 100},
}
chunkmanifest2 = ChunkManifest(entries=chunks_dict2)
marr1 = ManifestArray(zarray=zarray_common, chunkmanifest=chunkmanifest1)
Expand Down
Loading
Loading