Skip to content

Commit

Permalink
fixes #51 all annotations have been lost on backend update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Jäger committed Apr 1, 2020
1 parent 3e61ef0 commit 527bead
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0]
### Fixed
- SIA: Fixed all annotations lost bug. (see also https://github.com/l3p-cv/lost/issues/51)
* When a new annotation was created and deleted before a backend update was performed, SIA sent this annotation to backend for an db update
* The backend then tried to update a db record that did not exists which caused an exception.
* The result was that all annotation where lost

## [1.0.0] - 2019-10-17
### Added
- SIA: Delete annotation by hitting Backspace
Expand Down
15 changes: 9 additions & 6 deletions backend/lost/logic/sia.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,15 @@ def __update_annotations(self, annotations, two_d_type):
annotation_json['unchanged'].append(two_d_json)
self.db_man.save_obj(two_d)
elif annotation['status'] == "deleted":
two_d = self.db_man.get_two_d_anno(annotation['id']) #type: lost.db.model.TwoDAnno
two_d_json = self.__serialize_two_d_json(two_d)
annotation_json['deleted'].append(two_d_json)
for label in self.db_man.get_all_two_d_label(two_d.idx):
self.db_man.delete(label)
self.db_man.delete(two_d)
try:
two_d = self.db_man.get_two_d_anno(annotation['id']) #type: lost.db.model.TwoDAnno
two_d_json = self.__serialize_two_d_json(two_d)
annotation_json['deleted'].append(two_d_json)
for label in self.db_man.get_all_two_d_label(two_d.idx):
self.db_man.delete(label)
self.db_man.delete(two_d)
except KeyError:
print('SIA bug backend fix! Do not try to delete annotations that are not in db!')
elif annotation['status'] == "new":
annotation_data = annotation['data']
try:
Expand Down
12 changes: 12 additions & 0 deletions frontend/lost/src/components/SIA/lost-sia/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.1] - 2020-04-01
### Fixed
- Fixed all annotations lost bug. (see also https://github.com/l3p-cv/lost/issues/51)
* When a new annotation was created and deleted before a backend update was performed, SIA sent this annotation to backend for an db update
* The backend then tried to update a db record that did not exists which caused an exception.
* The result was that all annotation where lost
2 changes: 1 addition & 1 deletion frontend/lost/src/components/SIA/lost-sia/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lost-sia",
"version": "0.0.0-alpha-13",
"version": "0.0.1",
"description": "Single Image Annotatio Tool for LOST",
"author": "l3p-cv",
"license": "MIT",
Expand Down
19 changes: 14 additions & 5 deletions frontend/lost/src/components/SIA/lost-sia/src/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,9 @@ class Canvas extends Component{
prevLabel: anno.labelIds,
})
if(this.props.onAnnoSelect){
this.props.onAnnoSelect(newAnno)
if (newAnno !== null){
this.props.onAnnoSelect(newAnno)
}
}
return newAnnos
}
Expand All @@ -866,9 +868,13 @@ class Canvas extends Component{
if (mode){
newAnno = {...anno, mode:mode}
if (mode === modes.DELETED){
newAnno = {
...newAnno,
status: annoStatus.DELETED
if (anno.status !== annoStatus.NEW){
newAnno = {
...newAnno,
status: annoStatus.DELETED
}
} else {
newAnno = null
}
} else {
newAnno = {
Expand All @@ -879,7 +885,10 @@ class Canvas extends Component{
} else {
newAnno = {...anno}
}
filtered.push(newAnno)
if (newAnno !== null){
filtered.push(newAnno)
}
console.log('merge anno newAnno, anno, mode', newAnno, anno, mode)
const newAnnos = [...filtered]
return {newAnnos, newAnno}
}
Expand Down

0 comments on commit 527bead

Please sign in to comment.