Skip to content

Commit

Permalink
Merge branch 'master' of github.com:seung-lab/AnnotationEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollman committed Mar 6, 2024
2 parents 28dcb0a + 5850bba commit 16c3714
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
1 change: 0 additions & 1 deletion annotationengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def versions():
app.register_blueprint(views_bp)
db.init_app(app)
db.create_all()


@app.route("/health")
def health():
Expand Down
22 changes: 12 additions & 10 deletions annotationengine/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from flask import Response, abort, g, request, current_app
from flask_accepts import accepts
from flask_restx import Namespace, Resource, reqparse, inputs
from middle_auth_client import (
auth_requires_permission
)
from middle_auth_client import auth_requires_permission
from marshmallow import ValidationError
from caveclient.materializationengine import MaterializationClient
from caveclient.auth import AuthClient
Expand Down Expand Up @@ -120,7 +118,6 @@ def get_schema_from_service(annotation_type, endpoint):
def trigger_supervoxel_lookup(
aligned_volume_name: str, table_name: str, inserted_ids: list
):

# look up datastacks with this
datastacks = get_datastacks_from_aligned_volumes(aligned_volume_name)

Expand Down Expand Up @@ -192,7 +189,7 @@ def post(self, aligned_volume_name: str):
table_info = db.annotation.create_table(
table_name, schema_type, **metadata_dict
)
except (TableAlreadyExists):
except TableAlreadyExists:
abort(400, f"Table {table_name} already exists")
except Exception as e:
abort(400, str(e))
Expand Down Expand Up @@ -356,12 +353,17 @@ def put(self, aligned_volume_name: str, table_name: str, **kwargs):
annotations = data.get("annotations")

new_ids = []

updated_ids_mapping = {}
for annotation in annotations:
try:
updated_id = db.annotation.update_annotation(table_name, annotation)
((old_id, new_id),) = updated_id.items()
new_ids.append(new_id)
update_id_map = db.annotation.update_annotation(table_name, annotation)
((old_id, new_id),) = update_id_map.items()
new_ids.append(
new_id
) # send a list of new ids to the supervoxel lookup
updated_ids_mapping[old_id] = (
new_id # return a mapping of old to new ids
)
except UpdateAnnotationError as update_error:
abort(409, str(update_error))
except ValidationError as validation_error:
Expand All @@ -372,7 +374,7 @@ def put(self, aligned_volume_name: str, table_name: str, **kwargs):
trigger_supervoxel_lookup(aligned_volume_name, table_name, new_ids)
except Exception as e:
logging.error(f"Lookup SVID workflow failed: {e}")
return new_ids, 200
return updated_ids_mapping, 200

@auth_requires_permission(
"edit", table_arg="aligned_volume_name", resource_namespace="aligned_volume"
Expand Down
7 changes: 3 additions & 4 deletions annotationengine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def wkb_to_numpy(wkb, convert_to_nm=None):
""" Fixes single geometry column """
"""Fixes single geometry column"""
shp = to_shape(wkb)
xyz_voxel = np.array([shp.xy[0][0], shp.xy[1][0], shp.z], dtype=np.int)
if convert_to_nm is not None:
Expand Down Expand Up @@ -61,7 +61,6 @@ def index():
"view", table_arg="aligned_volume_name", resource_namespace="aligned_volume"
)
def aligned_volume_view(aligned_volume_name):

db = get_db(aligned_volume_name)
table_names = db.database._get_existing_table_names()
query = (
Expand Down Expand Up @@ -116,8 +115,8 @@ def table_view(aligned_volume_name, table_name):
db = get_db(aligned_volume_name)
check_read_permission(db, table_name)
md = db.database.get_table_metadata(table_name)
if md['reference_table']:
RefModel = db.database.cached_table(md['reference_table'])
if md["reference_table"]:
RefModel = db.database.cached_table(md["reference_table"])
Model = db.database._get_model_from_table_name(table_name)
table_size = db.database.get_annotation_table_size(table_name)
query = db.database.cached_session.query(Model).limit(15)
Expand Down

0 comments on commit 16c3714

Please sign in to comment.