def watch_folder(folder, batch_size):
count = 0
classes = os.listdir(folder)
class_count = len(classes)
files = []
dirs = []
for cls in classes:
class_dir = os.path.join(folder, cls)
fls = os.listdir(class_dir)
count += len(fls)
files.append(fls)
dirs.append(class_dir)
if count >= batch_size:
dataset = Dataset.create(project='data-repo')
dataset.add_files(folder)
dataset.upload()
dataset.finalize()
dataset.publish()
for i in range(class_count):
f = os.listdir(files[i])
d = dirs[i]
for fname in f:
os.remove(os.path.join(d, fname))
scheduler = TaskScheduler()
scheduler.add_task(schedule_fn=watch_folder,)
there are other parameters for add_task as well, I'm just curious as to how do I pass the folder and batch size in the schedule_fn=watch_folder part