Skip to content

Commit 8c45a7b

Browse files
committed
update how inline references are handled v2
1 parent 0063062 commit 8c45a7b

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

virtualizarr/parsers/dmrpp.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
import io
23
import warnings
34
from pathlib import Path
@@ -15,7 +16,6 @@
1516
ManifestGroup,
1617
ManifestStore,
1718
)
18-
from virtualizarr.manifests.manifest import ChunkEntry
1919
from virtualizarr.manifests.utils import create_v3_array_metadata
2020
from virtualizarr.parsers.utils import encode_cf_fill_value
2121

@@ -198,13 +198,23 @@ def parse_dataset(
198198
meta["attributes"]["_FillValue"] = encoded_cf_fill_value
199199

200200
if "inline" in meta:
201-
# chunkmanifest is empty - extract inline data from dict
201+
# extract data already decoded into array/string
202202
data = meta.pop("inline", None)
203-
shape = meta.pop("shape", None)
204-
chunk_entry = ChunkEntry(
205-
path="__inlined__", offset=0, length=len(data), data=data
206-
)
207-
chunkmanifest = ChunkManifest(entries=chunk_entry, shape=shape)
203+
bdata = base64.b64encode(data)
204+
# chunk_entry = ChunkEntry(
205+
# path="", offset=0, length=len(bdata), data=bdata
206+
# )
207+
# chunkmanifest = ChunkManifest(entries=chunk_entry)
208+
209+
chunks = {
210+
"0.0": {
211+
"path": "__inline__",
212+
"offset": 0,
213+
"length": len(bdata),
214+
"data": bdata,
215+
},
216+
}
217+
chunkmanifest = ChunkManifest(entries=chunks)
208218
else:
209219
chunkmanifest = ChunkManifest(chunkmanifest)
210220

virtualizarr/tests/test_parsers/test_dmrpp.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,16 +564,21 @@ def test_dmrpp_missing_attrib_validation(dmrpp_xml_with_missing_attrib):
564564
assert manifest_store._group is not None
565565

566566

567-
@pytest.mark.xfail(
568-
reason="inline reference is failing locally",
569-
)
570567
@requires_network
571568
def test_inlinevalue():
569+
"""
570+
Test that inline values can be parsed into manifest
571+
"""
572+
expected_bytes = b"AAAAAAAAAAABAAAAAAAAAAIAAAAAAAAAAwAAAAAAAAAEAAAAAAAAAAUAAAAAAAAABgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAACQAAAAAAAAA="
573+
572574
dmrpp_file = (
573575
"http://test.opendap.org/opendap/data/dmrpp/compact_lowlevel.h5.dmrpp.file"
574576
)
575577
session = requests.Session()
576578
dmrpp = session.get(dmrpp_file).content.decode()
577579
parser = dmrparser(dmrpp, filepath="file:///")
578580
store = obstore_local(url=parser.data_filepath)
579-
parser.parse_dataset(object_store=store)
581+
ms = parser.parse_dataset(object_store=store)
582+
vds = ms.to_virtual_dataset()
583+
assert "my_dataset" in vds
584+
assert ms._group["my_dataset"]._manifest._inlined == {(0, 0): expected_bytes}

0 commit comments

Comments
 (0)