fix BUG-98 (user cancel of a job not dealing with dependant jobs) & constrain the width of the chosen face in DBox for overrides/create refimg

This commit is contained in:
2022-07-19 20:45:54 +10:00
parent 382647a91b
commit fd79ee2cf4
4 changed files with 36 additions and 14 deletions

2
BUGs
View File

@@ -2,5 +2,3 @@
BUG-97: if restart a job, we reset start time too (debatable) -
prob. better making a job have anull start time rather than now() as default, then if its null set it when we run the job
(this would set it at actual run time not create time, and if we restart, it would leave orig start time correct)
BUG-98: if you cancel a job (say the importdir job), then the getfiles dies
(should cascade the cancel through any that are waiting on this job OR 2nd job should not start if 1st job failed/withdrawn)

2
TODO
View File

@@ -11,6 +11,7 @@
--> need to test the 'override' when we re-ai-match (AFTER re-build from FS)
* capture pa_job_manager logs in prod
- redir'd to /var/log/pa* but NO content, seems wrong
* should I change the rotation code to use that jpeg util to reduce/remove compression loss?
@@ -29,7 +30,6 @@
--> OR? https://jsmpeg.com/
--> OR? convert all videos to mp4/webm
* delete folder
* allow joblog search (less needed with logs visible on a given file now)

View File

@@ -422,17 +422,17 @@ function FaceDBox(key, item)
face_pos=item[key]['which_face']
div ='<div class="col-6"><p>'
div+='Face position #' + face_pos
div+='<div id="face_img"></div>'
// use w-100 to force width to not make face image wider than half the dbox
div+='</p><div class="col-6 w-100"> <img id="face_img" class="w-100"></img></div>'
$.ajax({ type: 'POST', data: null, url: '/get_face_from_image/'+item[key].id,
success: function(img_data) {
item[key].refimg_data=img_data
$('#face_img').html( '<img src="data:image/jpeg;base64,' + img_data + '"></img>' )
// used for create_new_person only, so this will do nothing for
// option menu items
$('#face_img').prop('src', 'data:image/jpeg;base64,' + img_data )
// used for create_new_person only, so this will do nothing for option menu items
$('#refimg_data').val(img_data)
}
} )
div+='</p></div><div class="col-6">'
div+='</div><div class="col-6">'
if ( key == 'remove_override_force_match' )
{
if( objs[current].faces[face_pos].override.type_name == 'Manual match to existing person' )
@@ -468,6 +468,7 @@ function FaceDBox(key, item)
`
div+='<button class="btn btn-primary offset-3 col-2" type="button"'
div+='onClick="CreatePersonAndRefimg(\''+key+'\')">Save</button>'
div+='</div>'
}
if ( key == 'no_match_new_refimg' )
{

35
job.py
View File

@@ -104,6 +104,31 @@ def NewJob(name, num_files="0", wait_for=None, jex=None ):
WakePAJobManager()
return job
################################################################################
# WithdrawDependantJobs: for a stale job (pa_job_mgr restarts and a job is not
# finished), this function is called if the user chooses to cancel the job. It
# cancels this job, and any dependant jobs as well
################################################################################
def WithdrawDependantJobs( job, id, reason ):
for j in Job.query.filter(Job.wait_for==id).all():
FinishJob(j, f"Job (#{j.id}) has been cancelled -- #{job.id} {reason}", "Withdrawn" )
WithdrawDependantJobs(j, j.id, reason)
return
##############################################################################
# FinishJob(): finish this job off (if no overrides), its just marked completed
##############################################################################
def FinishJob(job, last_log, state="Completed", pa_job_state="Completed"):
job.state=state
job.pa_job_state=pa_job_state
job.last_update=datetime.now(pytz.utc)
log=Joblog( job_id=job.id, log=last_log, log_date=job.last_update )
db.session.add(log)
if job.state=="Failed":
WithdrawDependantJobs( job, job.id, "dependant job failed" )
db.session.commit()
return
################################################################################
# /jobs -> show jobs (default to only showing 'non-archived' jobs -- age is in
# settings.job_archive_age
@@ -185,13 +210,11 @@ def stale_job(id):
job.num_files=0
job.current_file=''
job.current_file_num=0
job.last_update=now
db.session.add(log)
elif request.form['action'] == "cancel":
log=Joblog( job_id=id, log="(Stale) Job withdrawn manually by user", log_date=now )
job.pa_job_state='Completed'
job.state='Withdrawn'
job.last_update=now
db.session.add(log)
WithdrawDependantJobs( job, job.id, "(Stale) Job withdrawn manually by user" )
FinishJob(job, f"Job (#{job.id}) (Stale) Job withdrawn manually by user", "Withdrawn" )
# clear out message for this job being stale (and do this via raw sql to
# avoid circulr import)