Skip to content

Conversation

@TrevorBurgoyne
Copy link
Member

@TrevorBurgoyne TrevorBurgoyne commented May 2, 2025

Fix/empty layers

Description

  • Fix bug where empty polygon layers could be included in a submit_button hook payload.

Testing

A user of ULabel found that empty [] layers were occasionally present in the polygon annotations provided by the ULabel submit button hook. I have been unable to get this to occur during normal operation of ULabel, but instead have added a fix to prevent these empty layers from being present when delivered through the submit button.

By adding an empty [] layer to the resume_from.html in the demo, I confirmed that these get removed on load into ULabel when they are loaded in via ULabelAnnotation.from_json(). So now we perform the same operation when preparing annotations to be delivered when a submit button hook is called.

I confirmed that this removes empty layers by adding the following code to index.js at line 353:

if (cand["id"] == "d0f9b427-123d-46c0-a131-84db3f002b6f") {
    cand["spatial_payload"].push([]);
    console.log(cand["spatial_payload"]);
}

When running the demo resume_from.html, this forcibly adds an empty layer to one of the annotations after it has been initialized. I confirmed that pressing the Submit button successfully removes the empty layer in the delivered annotations.

PR Checklist

  • Merged latest main
  • Version number in package.json has been bumped since last release
  • Version numbers match between package package.json and src/version.js
  • Ran npm install and npm run build AFTER bumping the version number
  • Updated documentation if necessary (currently just in api_spec.md)
  • Added changes to changelog.md

Breaking API Changes

no thanks

@TrevorBurgoyne TrevorBurgoyne added the bug Something isn't working label May 2, 2025
Comment on lines +2489 to +2494
try {
annotation = ULabelAnnotation.from_json(ulabel.subtasks[stkey]["annotations"]["access"][ulabel.subtasks[stkey]["annotations"]["ordering"][i]]);
} catch (e) {
console.error("Error validating annotation during submit.", e);
continue;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we ensure that the annotations being delivered are still valid ULabelAnnotation objects

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, although that line certainly make me want to write some annotation getters...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Covered in #198)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never ran into any errors with the loader but just to be safe i figured id add it

@TrevorBurgoyne TrevorBurgoyne requested a review from joshua-dean May 2, 2025 15:16
Copy link
Collaborator

@joshua-dean joshua-dean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TrevorBurgoyne TrevorBurgoyne merged commit 1b7eeb1 into main May 2, 2025
1 check passed
@TrevorBurgoyne TrevorBurgoyne deleted the fix/empty-layers branch May 2, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants