in scripts/maintenance/produce_videos.py [0:0]
def produce(p_nums, cleanup=False, parallel=True, ffmpeg_path='ffmpeg',
tasks=None):
if tasks is not None:
pass
elif cleanup:
print('#### Cleanup mode ####')
filename = osp.join('status.json')
with open(filename, 'r') as f:
status = json.load(f)
tasks = []
for task,done in status.items():
if done:
continue
task = task.split('_')
p_num = int(task[0][4:])
intent = task[1]
object_name = '_'.join(task[2:])
tasks.append((p_num, intent, object_name))
print('Found {:d} cleanup items'.format(len(tasks)))
else:
tasks = list(itertools.product(p_nums, intents, object_names))
worker = partial(produce_worker, ffmpeg_path=ffmpeg_path)
if parallel:
p = Pool(len(object_names))
dones = p.map(worker, tasks)
p.close()
p.join()
else:
dones = map(worker, tasks)
filename = osp.join('status.json')
d = {}
if osp.isfile(filename):
with open(filename, 'r') as f:
d = json.load(f)
for task, done in zip(tasks, dones):
d['full{:d}_{:s}_{:s}'.format(*task)] = done
with open(filename, 'w') as f:
json.dump(d, f, indent=4, separators=(', ', ': '))
print('{:s} updated'.format(filename))