Fixed: BUG-40: RunAI file counts broken
This commit is contained in:
3
BUGs
3
BUGs
@@ -1,4 +1 @@
|
||||
### Next: 44
|
||||
BUG-40: RunAI file counts are broken & current state is new when it should be in progress
|
||||
BUG-41: Ref img had wrong perms and when copied over for docker failed
|
||||
BUG-43: creating person and selecting the ref img, does not actually keep the ref image & if r.encodings is null, we sail on with the work - should just error out/stop the AI job
|
||||
|
||||
@@ -925,11 +925,11 @@ def JobImportDir(job):
|
||||
FinishJob(job, f"Finished Importing: {path} - Processed {overall_file_cnt} files, Removed {rm_cnt} file(s)")
|
||||
return
|
||||
|
||||
def RunFuncOnFilesInPath( job, path, file_func ):
|
||||
def RunFuncOnFilesInPath( job, path, file_func, count_dirs ):
|
||||
d = session.query(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==path).filter(Dir.rel_path=='').first()
|
||||
files = session.query(Entry).join(EntryDirLink).filter(EntryDirLink.dir_eid==d.eid).all()
|
||||
for e in files:
|
||||
ProcessFilesInDir(job, e, file_func)
|
||||
ProcessFilesInDir(job, e, file_func, count_dirs)
|
||||
return
|
||||
|
||||
|
||||
@@ -944,7 +944,7 @@ def JobProcessAI(job):
|
||||
for person in people:
|
||||
generateKnownEncodings(person)
|
||||
|
||||
RunFuncOnFilesInPath( job, path, ProcessAI )
|
||||
RunFuncOnFilesInPath( job, path, ProcessAI, True )
|
||||
|
||||
FinishJob(job, "Finished Processesing AI")
|
||||
return
|
||||
@@ -961,8 +961,16 @@ def WrapperForScanFileForPerson(job, entry):
|
||||
AddLogForJob( job, f'INFO: processing File: {entry.name}' )
|
||||
for person in ppl:
|
||||
ScanFileForPerson( job, entry, person.id, force=False)
|
||||
# processed this file, add 1 to count
|
||||
job.current_file_num+=1
|
||||
return
|
||||
|
||||
def AddToJobImageCount(job, entry ):
|
||||
if entry.type.name == 'Image':
|
||||
job.num_files += 1
|
||||
return
|
||||
|
||||
|
||||
def JobRunAIOn(job):
|
||||
AddLogForJob(job, f"INFO: Starting looking For faces in files job...")
|
||||
which_person=[jex.value for jex in job.extra if jex.name == "person"][0]
|
||||
@@ -971,21 +979,36 @@ def JobRunAIOn(job):
|
||||
else:
|
||||
ppl=session.query(Person).filter(Person.tag==which_person).all()
|
||||
|
||||
# FIXME: probably should be elsewhere, but this is optmised so if refimgs exist for ppl, then it wont regen them
|
||||
# for person in ppl:
|
||||
# generateKnownEncodings(person)
|
||||
# start by working out how many images in this selection we will need face match on
|
||||
job.num_files = 0
|
||||
for jex in job.extra:
|
||||
if 'eid-' in jex.name:
|
||||
entry=session.query(Entry).get(jex.value)
|
||||
if entry.type.name == 'Directory':
|
||||
# False in last param says, dont count dirs (we won't AI a dir entry itself)
|
||||
ProcessFilesInDir( job, entry, AddToJobImageCount, False )
|
||||
elif entry.type.name == 'Image':
|
||||
job.num_files += 1
|
||||
# update job, so file count UI progress bar will work
|
||||
# remember that ProcessFilesInDir updates the current_file_num so zero it out so we can start again
|
||||
job.current_file_num = 0
|
||||
print( f"about to commit: {job}" )
|
||||
session.commit()
|
||||
|
||||
for jex in job.extra:
|
||||
if 'eid-' in jex.name:
|
||||
entry=session.query(Entry).get(jex.value)
|
||||
if entry.type.name == 'Directory':
|
||||
ProcessFilesInDir( job, entry, WrapperForScanFileForPerson )
|
||||
# False in last param says, dont count dirs (we won't AI a dir entry itself)
|
||||
ProcessFilesInDir( job, entry, WrapperForScanFileForPerson, False )
|
||||
elif entry.type.name == 'Image':
|
||||
which_file=session.query(Entry).join(File).filter(Entry.id==jex.value).first()
|
||||
if DEBUG:
|
||||
AddLogForJob( job, f'INFO: processing File: {entry.name}' )
|
||||
for person in ppl:
|
||||
ScanFileForPerson( job, which_file, person.id, force=False)
|
||||
# processed this file, add 1 to count
|
||||
job.current_file_num+=1
|
||||
else:
|
||||
AddLogForJob( job, f'Not processing Entry: {entry.name} - not an image' )
|
||||
FinishJob(job, "Finished Processesing AI")
|
||||
@@ -1087,17 +1110,19 @@ def compareAI(known_encoding, unknown_encoding):
|
||||
return results
|
||||
|
||||
|
||||
def ProcessFilesInDir(job, e, file_func):
|
||||
def ProcessFilesInDir(job, e, file_func, count_dirs):
|
||||
if DEBUG==1:
|
||||
print( f"DEBUG: ProcessFilesInDir: {e.FullPathOnFS()}")
|
||||
if e.type.name != 'Directory':
|
||||
file_func(job, e)
|
||||
else:
|
||||
d=session.query(Dir).filter(Dir.eid==e.id).first()
|
||||
if count_dirs:
|
||||
print( f"{e.name} about to add 1 to cfn for a dir, {job.current_file_num}" )
|
||||
job.current_file_num+=1
|
||||
files = session.query(Entry).join(EntryDirLink).filter(EntryDirLink.dir_eid==d.eid).all()
|
||||
for sub in files:
|
||||
ProcessFilesInDir(job, sub, file_func)
|
||||
ProcessFilesInDir(job, sub, file_func, count_dirs)
|
||||
return
|
||||
|
||||
def JobGetFileDetails(job):
|
||||
@@ -1110,7 +1135,7 @@ def JobGetFileDetails(job):
|
||||
job.current_file_num = 0
|
||||
job.num_files = p.num_files
|
||||
session.commit()
|
||||
RunFuncOnFilesInPath( job, path_prefix, GenHashAndThumb )
|
||||
RunFuncOnFilesInPath( job, path_prefix, GenHashAndThumb, True )
|
||||
FinishJob(job, "File Details job finished")
|
||||
session.commit()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user