Skip to content

Commit

Permalink
Added delete_labelindices()
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarteberg committed Apr 13, 2022
1 parent 85f4e35 commit 0208c79
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion neuclease/dvid/labelmap/_labelindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def post_labelindex(server, uuid, instance, label, proto_index, *, session=None)
r = session.post(f'{server}/api/node/{uuid}/{instance}/index/{label}', data=payload)
r.raise_for_status()


@dvid_api_wrapper
def post_labelindices(server, uuid, instance, indices, *, session=None):
"""
Expand Down Expand Up @@ -206,6 +205,28 @@ def post_labelindices(server, uuid, instance, indices, *, session=None):
post_labelindex_batch = post_labelindices


@dvid_api_wrapper
def delete_labelindices(server, uuid, instance, bodies, *, session=None):
"""
Delete the label indexes for a list of bodies.
DVID supports deletion en masse via POST of empty label index prototbuf structures.
(See the DVID docs for POST .../index and POST .../indices)
"""
index_list = []
for body in bodies:
li = LabelIndex()
li.label = int(body)
index_list.append(li)

indices = LabelIndices()
indices.indices.extend(index_list)
payload = indices.SerializeToString()

endpoint = f'{server}/api/node/{uuid}/{instance}/indices'
r = session.post(endpoint, data=payload)
r.raise_for_status()


def copy_labelindices(src_triple, dest_triple, labels, *, batch_size=10_000, threads=None, processes=None):
"""
Copy many labelindexes from one dvid repo to another, in batches.
Expand Down

0 comments on commit 0208c79

Please sign in to comment.