Repository navigation
Script for matching User Edits - #2038
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a way to find out which user last saved each track in a DIVE dataset. Users ask for this regularly ("which human made which annotations?"). The data was already there: each saved track version's
rev_createdpoints at arevisionLogItementry that records the author. Until now, joining the two meant digging through MongoDB by hand.This PR adds:
GET /dive_annotation/track/authors: a new endpoint that lists each track visible at a revision with the revision that saved it and that revision's author.samples/scripts/userEdits/trackAuthors.py: a uv script for ops and admin work that needs more than the API exposes: full version history, per-feature frames, frame-to-image-name mapping, and a dump of the revision log.A save rewrites the whole track, so the author is the last user to change the track, not necessarily the creator of every detection. The route description and docs say so.
Endpoint:
GET /dive_annotation/track/authorsExample row:
{ "id": 1, "begin": 0, "end": 33, "featureCount": 34, "rev_created": 17, "author_id": "…", "author_name": "jdoe", "created": "…", "description": "Import VIAME_CSV from output_tracks.csv" }descriptionshows where a version came from:saveis a manual edit in the annotator,Import <type> from <file>is an uploaded file or pipeline output.revisionandsetbehave exactly as they do on/track. The visibility query is pulled out ofBaseItem.list()into a sharedBaseItem.list_query(), which both routes use.featuresare not returned. Mongo counts them in the projection (featureCount), so long tracks don't bloat the response.revisionLogItemquery covering every distinct revision on the page.limit/offset, with the total in theGirder-Total-Countheader./dive_annotation/revision, which already exposes author names.annotation_params()helper, also used by/trackand/group, so they can't drift apart.Sample script:
samples/scripts/userEdits/trackAuthors.pyReads MongoDB directly. It bypasses Girder access control, so it's meant for admins; everyone else should use the endpoint. Track fields use the same names as the endpoint, so output built on the script keeps working after switching to the API.
--all-versionsincludes replaced and deleted versions.--featuresadds each feature's frame, image name, keyframe and interpolate flags.--revisionsadds the dataset's full revision log.valid_imagesdoes: png/jpg/jpeg only, names sorted with numbers in numeric order, and clones followed back to their source media throughforeign_media_id.--container <name>finds the Mongo container's IP withdocker inspect, since the default docker-compose doesn't publish port 27017. It fails after 5 seconds with a hint if Mongo can't be reached.Docs
docs/scripting/Endpoints.md: documentsdive_annotation/track/authors.samples/scripts/userEdits/README.md: usage, output format, when to use the API instead, and the Mongo access caveat.Testing
server/tests/test_track_authors.py: authors are matched to the right tracks,featuresare left out of the projection, one revision-log query covers the page, and a track with no revision-log entry is still listed with an empty author.test_annotation_rollback.pystill passes.revision=return the expected tracks.track_authorsreturns in about 0.5s./trackand rejects requests that aren't logged in. A logged-in HTTP request has not been tested yet.Known limitations
featureCountuses a$sizeexpression in the find projection, which needs MongoDB 4.4+. docker-compose pins 5.0.createdtimestamps are written without a timezone; they are UTC.