Skip to content
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
20 changes: 19 additions & 1 deletion pychunkedgraph/app/segmentation/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,11 @@ def merge_log(table_id, root_id):

def _parse_timestamp(arg_name, default_timestamp=0, return_datetime=False):
"""Convert seconds since epoch to UTC datetime."""
timestamp = request.args.get(arg_name, default_timestamp)
if timestamp is None:
raise (cg_exceptions.BadRequest(f"Timestamp parameter {arg_name} is mandatory"))
try:
timestamp = float(request.args.get(arg_name, default_timestamp))
timestamp = float(timestamp)
if return_datetime:
return datetime.fromtimestamp(timestamp, UTC)
else:
Expand Down Expand Up @@ -1191,3 +1194,18 @@ def parse_attr(attr, val) -> str:
details[_k] = _v
result[int(k)] = details
return result


### DELTA ROOTS ------------------------------------------------------------


def delta_roots(table_id):
current_app.table_id = table_id

timestamp_past = _parse_timestamp("timestamp_past", None, return_datetime=True)
timestamp_future = _parse_timestamp(
"timestamp_future", time.time(), return_datetime=True
)
cg = app_utils.get_cg(table_id)
old_roots, new_roots = cg.get_proofread_root_ids(timestamp_past, timestamp_future)
return {"old_roots": old_roots, "new_roots": new_roots}
11 changes: 11 additions & 0 deletions pychunkedgraph/app/segmentation/v1/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,14 @@ def operation_details(table_id):
int64_as_str = request.args.get("int64_as_str", default=False, type=toboolean)
resp = common.operation_details(table_id)
return jsonify_with_kwargs(resp, int64_as_str=int64_as_str)


### GET PROOFREAD IDS --------------------------------------------------------


@bp.route("/table/<table_id>/delta_roots", methods=["GET"])
@auth_requires_permission("view")
def delta_roots(table_id):
int64_as_str = request.args.get("int64_as_str", default=False, type=toboolean)
resp = common.delta_roots(table_id)
return jsonify_with_kwargs(resp, int64_as_str=int64_as_str)