From a1245151d3a4d3965f04560d5b6ec420ec4c1cec Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 17 Jul 2022 15:32:59 +1000 Subject: [PATCH] when restart JobRunAIOnPath, dont add the path again, move a couple of debug lines to an actual debug --- pa_job_manager.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pa_job_manager.py b/pa_job_manager.py index 30fa2ee..338247d 100644 --- a/pa_job_manager.py +++ b/pa_job_manager.py @@ -745,7 +745,7 @@ def HandleJobs(first_run=False): print("INFO: PA job manager is starting up - check for stale jobs" ) else: if DEBUG: - print("INFO: PA job manager is scanning for new jobs to process") + print("DEBUG: PA job manager is scanning for new jobs to process") for job in session.query(Job).filter(Job.pa_job_state != 'Complete').all(): if first_run and job.pa_job_state == 'In Progress': print( f"INFO: Found stale job#{job.id} - {job.name}" ) @@ -1482,7 +1482,16 @@ def JobRunAIOnPath(job): for p in paths: d = session.query(Dir).join(PathDirLink).filter(PathDirLink.path_id==p.id).filter(Dir.rel_path=='').first() DelMatchesForDir( job, d.eid ) - job.extra.append( JobExtra( name=f"eid-{path_cnt}", value=f"{d.eid}" ) ) + # small chance we are restarting a job (and this is the one that is likely to be 'stale' and restarted, so accommodate + # this by not adding it twice -- only really throws count out and makes it 're-process', but if this say the storage path, + # that can be another 10s of thousands of files to re-AI over... + already_there=False + for ex in job.extra: + if ex.name == f"eid-{path_cnt}": + already_there=True + break + if not already_there: + job.extra.append( JobExtra( name=f"eid-{path_cnt}", value=f"{d.eid}" ) ) path_cnt+=1 JobRunAIOn(job) return @@ -2067,7 +2076,8 @@ def ScanFileForPerson( job, e, force=False ): threshold = settings.default_threshold # add log, set current_file and increment file_num in job - ProcessFileForJob( job, f'INFO: processing File: {e.name} and threshold face distance of {threshold}', e.name ) + if DEBUG: + ProcessFileForJob( job, f'DEBUG: processing File: {e.name} and threshold face distance of {threshold}', e.name ) file_h = session.query(File).get( e.id ) # if we are forcing this, delete any old faces (this will also delete linked tables), and reset faces_created_on to None if force: