Skip to content

Commit

Permalink
feat(python): Migrate vizarr to zarrita bindings (#185)
Browse files Browse the repository at this point in the history
* feat: Migrate to zarrita in Python bindings

* chore: Bump v0.1.0
  • Loading branch information
manzt authored Jul 19, 2024
1 parent 5c6d5b6 commit 9b77d4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "vizarr"
version = "0.0.3"
version = "0.1.0"
dependencies = ["anywidget", "zarr"]

[project.optional-dependencies]
Expand Down
20 changes: 4 additions & 16 deletions python/src/vizarr/_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,18 @@ function get_source(model, source) {
return {
/**
* @param {string} key
* @return {Promise<ArrayBuffer>}
* @return {Promise<Uint8Array | undefined>}
*/
async getItem(key) {
async get(key) {
const { data, buffers } = await send(model, {
type: "get",
source_id: source.id,
key,
});
if (!data.success) {
throw { __zarr__: "KeyError" };
return undefined;
}
return buffers[0].buffer;
},
/**
* @param {string} key
* @return {Promise<boolean>}
*/
async containsItem(key) {
const { data } = await send(model, {
type: "has",
source_id: source.id,
key,
});
return data;
return new Uint8Array(buffers[0].buffer);
},
};
}
Expand Down

0 comments on commit 9b77d4b

Please sign in to comment.