Skip to content

Commit

Permalink
Fix #120: Added **Force Annotation Release**-button
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeger-j committed Feb 25, 2021
1 parent 66398e3 commit 7cca6ab
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ 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.4.0] - unreleased
## [1.4.0] - 2021-02-25
### Added
- SIA:
* Added maxAnnos to canvasConfig. This allows to define a maximum number of annotations that are allowed per image.
- Pipeline View:
* Added **Force Annotation Release**-button in running pipeline view for annotation tasks in order to manually release annotations that are locked for inactive users (fixes https://github.com/l3p-cv/lost/issues/120)
### Changed
- to_dict()/to_df() method for annotation export -> use annotator.user_name for annotator entry in dict/dataframe
### Fixed
- db.access -> Use with_for_update method when locking images for an annotator in SIA tasks to prevent assignment of same image to multiple annotators


## [1.3.1] - 2020-12-15
### Change
- Refactor User Management frontend with using reactstrap
Expand Down
2 changes: 1 addition & 1 deletion backend/lost/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.1'
__version__ = '1.4.0'
17 changes: 17 additions & 0 deletions backend/lost/api/annotask/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from lost.db import access, roles
from lost.api.annotask.parsers import annotask_parser
from lost.logic import anno_task as annotask_service
from lost.logic.jobs.jobs import force_anno_release
from lost.logic.report import Report
import json

Expand Down Expand Up @@ -101,3 +102,19 @@ def post(self):
report_data = report.get_report()
dbm.close_session()
return report_data

@namespace.route('/force_release/<int:annotask_id>')
@namespace.param('annotask_id', 'The id of the annotation task.')
class ForceRelease(Resource):
@jwt_required
def get(self, annotask_id):
dbm = access.DBMan(LOST_CONFIG)
identity = get_jwt_identity()
user = dbm.get_user_by_id(identity)
if not user.has_role(roles.ANNOTATOR):
dbm.close_session()
return "You are not authorized.", 401
else:
force_anno_release(dbm, annotask_id)
dbm.close_session()
return "Success", 200
20 changes: 20 additions & 0 deletions backend/lost/logic/jobs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ def exec_pipe():
dbm.close_session()


def force_anno_release(dbm, anno_task_id):
'''Force a release of all annotations that are currently locked by a user for annotation
Args:
dbm (DBMan): Database manager
anno_task_id (int): Id of the annotation task
'''
c_imgs = 0
c_2dannos = 0
for anno in dbm.get_locked_img_annos(anno_task_id):
anno.state = state.Anno.UNLOCKED
dbm.add(anno)
c_imgs += 1
for anno in dbm.get_locked_two_d_annos(anno_task_id):
anno.state = state.Anno.UNLOCKED
dbm.add(anno)
c_2dannos += 1
dbm.commit()
return c_imgs, c_2dannos

def release_annos_by_timeout(dbm, timeout):
'''Release annotations based on timeout
Expand Down
9 changes: 9 additions & 0 deletions frontend/lost/src/actions/annoTask/annoTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export const chooseAnnoTask = (id, callBack) => async dispatch => {
}
}

export const forceAnnotationRelease = (id, callBack) => async dispatch => {
try {
await axios.get(API_URL + `/annotask/force_release/${id}`)

callBack()
} catch(e){

}
}

export const getAnnoTaskStatistic = (id) => async dispatch => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import actionsAll from '../../../../../../actions'


const {toggleModal} = actions
const {siaReviewSetElement, chooseAnnoTask} = actionsAll
const {siaReviewSetElement, chooseAnnoTask, forceAnnotationRelease} = actionsAll

class BaseModal extends Component {
constructor() {
Expand All @@ -37,6 +37,7 @@ class BaseModal extends Component {
<AnnoTaskModal
siaReviewSetElement={this.props.siaReviewSetElement}
chooseAnnoTask={this.props.chooseAnnoTask}
forceAnnotationRelease={this.props.forceAnnotationRelease}
{...this.props.data}
/>
)
Expand Down Expand Up @@ -92,5 +93,5 @@ const mapStateToProps = (state) => {

export default connect(
mapStateToProps,
{toggleModal, siaReviewSetElement, chooseAnnoTask}
{toggleModal, siaReviewSetElement, chooseAnnoTask, forceAnnotationRelease}
)(BaseModal)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react'
import { ModalHeader, ModalBody, Button } from 'reactstrap';
import Table from '../../../../globalComponents/modals/Table'
import CollapseCard from '../../../../globalComponents/modals/CollapseCard'
import { alertSuccess } from '../../../../globalComponents/Sweetalert'

import { createHashHistory } from 'history'

function handleSiaRewiewClick(props){
Expand All @@ -12,6 +14,15 @@ function handleSiaRewiewClick(props){
)
}

function annotationReleaseSuccessful(){
// console.log('Annotation release successful')
alertSuccess('Annotation release successful')
}

function handleForceAnnotationRelease(props){
// console.log('Start annotation release')
props.forceAnnotationRelease(props.annoTask.id, annotationReleaseSuccessful)
}
export default (props)=>{
return (
<>
Expand Down Expand Up @@ -57,6 +68,8 @@ export default (props)=>{
</CollapseCard>
<Button color="warning" style={{ marginLeft:10, marginTop:20, marginBottom: '1rem' }}
onClick={e => handleSiaRewiewClick(props)}>Review Annotations</Button>
<Button color="danger" style={{ marginLeft:10, marginTop:20, marginBottom: '1rem' }}
onClick={e => handleForceAnnotationRelease(props)}>Force Annotation Release</Button>

</ModalBody>
</>
Expand Down

0 comments on commit 7cca6ab

Please sign in to comment.