Skip to content

Fix bug in slicing into container adapter #635

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

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions tiled/_tests/test_container_files.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io

import h5py
import pandas
import pytest
Expand Down Expand Up @@ -61,3 +63,6 @@ async def test_hdf5(tmpdir):
tree(client)
client["h"]["x"].read()
client["h"]["g"]["y"].read()

buffer = io.BytesIO()
client.export(buffer, format="application/json")
12 changes: 12 additions & 0 deletions tiled/_tests/test_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Persistent stores are being developed externally to the tiled package.
"""
import base64
import io
from datetime import datetime

import awkward
Expand Down Expand Up @@ -433,3 +434,14 @@ async def test_bytes_in_metadata(tree):
assert value.startswith("data:application/octet-stream;base64,")
label, encoded = value.split(",", 1)
assert base64.b64decode(encoded) == b"raw_bytes"


@pytest.mark.asyncio
async def test_container_export(tree):
with Context.from_app(build_app(tree)) as context:
client = from_context(context)

a = client.create_container("a")
a.write_array([1, 2, 3], key="b")
buffer = io.BytesIO()
client.export(buffer, format="application/json")
4 changes: 2 additions & 2 deletions tiled/catalog/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ class CatalogContainerAdapter(CatalogNodeAdapter):
async def keys_range(self, offset, limit):
if self.data_sources:
return (await self.get_adapter()).keys()[
offset : offset + limit # noqa: E203
offset : (offset + limit) if limit is not None else None # noqa: E203
]
statement = select(orm.Node.key).filter(orm.Node.ancestors == self.segments)
for condition in self.conditions:
Expand All @@ -781,7 +781,7 @@ async def keys_range(self, offset, limit):
async def items_range(self, offset, limit):
if self.data_sources:
return (await self.get_adapter()).items()[
offset : offset + limit # noqa: E203
offset : (offset + limit) if limit is not None else None # noqa: E203
]
statement = select(orm.Node).filter(orm.Node.ancestors == self.segments)
for condition in self.conditions:
Expand Down