diff --git a/BUGs b/BUGs index 26388f3..d33f840 100644 --- a/BUGs +++ b/BUGs @@ -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) diff --git a/TODO b/TODO index b6aae8a..a349d71 100644 --- a/TODO +++ b/TODO @@ -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) diff --git a/internal/js/view_support.js b/internal/js/view_support.js index a239401..afa3aca 100644 --- a/internal/js/view_support.js +++ b/internal/js/view_support.js @@ -422,17 +422,17 @@ function FaceDBox(key, item) face_pos=item[key]['which_face'] div ='

' div+='Face position #' + face_pos - div+='

' + // use w-100 to force width to not make face image wider than half the dbox + 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( '' ) - // 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+='

' + div+='
' 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+='' + div+='
' } if ( key == 'no_match_new_refimg' ) { diff --git a/job.py b/job.py index 3448984..ca292d8 100644 --- a/job.py +++ b/job.py @@ -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)