This commit is contained in:
2025-08-28 12:38:34 -04:00
parent 571500b291
commit 028149b786

View File

@@ -26,17 +26,26 @@ default_dir_watch = settings.dir_watch
publish = kwq.producer.send
topic = kwq.TOPICS.videos_to_score_detection
necessary_extensions = [
'.oclip_embeds.npz',
'.json',
'.db_has_sl2_embeds_part' ]
def decide_to_put_in_queue(file_name):
disqualifiers = list()
disqualifiers.append(not os.path.exists(file_name))
disqualifiers.append("_reduced" in file_name)
disqualifiers.append("_trimmed" in file_name)
disqualified = any(disqualifiers)
if file_name.endswith(".mp4") and not disqualified:
return True
rt_path, _ = os.path.splitext(file_name)
all_exist = all([os.path.exists( rt_path + ext) for ext in necessary_extensions])
return (not all_exist)
else:
return False
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(parent_dir)
def place_file_in_queue(filef):
@@ -60,7 +69,7 @@ def place_file_in_queue(filef):
wq.publish(wq.TOPICS.ml_vision_to_score, filef)
def add_files_to_queue(paths):
def add_files_to_queue(paths, dry_run = False):
queued = set()
for rt in paths:
for root, dirs, files in os.walk(rt):
@@ -71,6 +80,9 @@ def add_files_to_queue(paths):
for x in queued:
if dry_run:
print('DRY RUN, CANDIDATES FOR QUEUE: ' + x)
else:
place_file_in_queue(x)
@@ -81,13 +93,14 @@ if __name__ == "__main__":
)
parser.add_argument("paths", nargs="*", help="Paths to monitor", default=())
parser.add_argument("--dry-run", action='store_true', help='Dry Run')
args, _ = parser.parse_known_args()
paths = args.paths
dry_run = args.dry_run
if len(paths) == 0:
paths = default_dir_watch
add_files_to_queue(paths)
add_files_to_queue(paths, dry_run = dry_run)