Skip to content

Commit 527bead

Browse files
author
Jonas Jäger
committed
fixes #51 all annotations have been lost on backend update
1 parent 3e61ef0 commit 527bead

File tree

5 files changed

+43
-12
lines changed

5 files changed

+43
-12
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.1.0]
8+
### Fixed
9+
- SIA: Fixed all annotations lost bug. (see also https://github.com/l3p-cv/lost/issues/51)
10+
* When a new annotation was created and deleted before a backend update was performed, SIA sent this annotation to backend for an db update
11+
* The backend then tried to update a db record that did not exists which caused an exception.
12+
* The result was that all annotation where lost
13+
714
## [1.0.0] - 2019-10-17
815
### Added
916
- SIA: Delete annotation by hitting Backspace

backend/lost/logic/sia.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,15 @@ def __update_annotations(self, annotations, two_d_type):
312312
annotation_json['unchanged'].append(two_d_json)
313313
self.db_man.save_obj(two_d)
314314
elif annotation['status'] == "deleted":
315-
two_d = self.db_man.get_two_d_anno(annotation['id']) #type: lost.db.model.TwoDAnno
316-
two_d_json = self.__serialize_two_d_json(two_d)
317-
annotation_json['deleted'].append(two_d_json)
318-
for label in self.db_man.get_all_two_d_label(two_d.idx):
319-
self.db_man.delete(label)
320-
self.db_man.delete(two_d)
315+
try:
316+
two_d = self.db_man.get_two_d_anno(annotation['id']) #type: lost.db.model.TwoDAnno
317+
two_d_json = self.__serialize_two_d_json(two_d)
318+
annotation_json['deleted'].append(two_d_json)
319+
for label in self.db_man.get_all_two_d_label(two_d.idx):
320+
self.db_man.delete(label)
321+
self.db_man.delete(two_d)
322+
except KeyError:
323+
print('SIA bug backend fix! Do not try to delete annotations that are not in db!')
321324
elif annotation['status'] == "new":
322325
annotation_data = annotation['data']
323326
try:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [0.0.1] - 2020-04-01
8+
### Fixed
9+
- Fixed all annotations lost bug. (see also https://github.com/l3p-cv/lost/issues/51)
10+
* When a new annotation was created and deleted before a backend update was performed, SIA sent this annotation to backend for an db update
11+
* The backend then tried to update a db record that did not exists which caused an exception.
12+
* The result was that all annotation where lost

frontend/lost/src/components/SIA/lost-sia/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lost-sia",
3-
"version": "0.0.0-alpha-13",
3+
"version": "0.0.1",
44
"description": "Single Image Annotatio Tool for LOST",
55
"author": "l3p-cv",
66
"license": "MIT",

frontend/lost/src/components/SIA/lost-sia/src/Canvas.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,9 @@ class Canvas extends Component{
853853
prevLabel: anno.labelIds,
854854
})
855855
if(this.props.onAnnoSelect){
856-
this.props.onAnnoSelect(newAnno)
856+
if (newAnno !== null){
857+
this.props.onAnnoSelect(newAnno)
858+
}
857859
}
858860
return newAnnos
859861
}
@@ -866,9 +868,13 @@ class Canvas extends Component{
866868
if (mode){
867869
newAnno = {...anno, mode:mode}
868870
if (mode === modes.DELETED){
869-
newAnno = {
870-
...newAnno,
871-
status: annoStatus.DELETED
871+
if (anno.status !== annoStatus.NEW){
872+
newAnno = {
873+
...newAnno,
874+
status: annoStatus.DELETED
875+
}
876+
} else {
877+
newAnno = null
872878
}
873879
} else {
874880
newAnno = {
@@ -879,7 +885,10 @@ class Canvas extends Component{
879885
} else {
880886
newAnno = {...anno}
881887
}
882-
filtered.push(newAnno)
888+
if (newAnno !== null){
889+
filtered.push(newAnno)
890+
}
891+
console.log('merge anno newAnno, anno, mode', newAnno, anno, mode)
883892
const newAnnos = [...filtered]
884893
return {newAnnos, newAnno}
885894
}

0 commit comments

Comments
 (0)