import os
import sys

from custom.utils.sync.aws import aws_s3_ls

s3_path_east = 's3://tri-ml-datasets'
s3_path_west = 's3://tri-ml-sandbox-16011-us-west-2-datasets'

script = 'python externals/vidar/scripts/datasets/sync/sync_from_raw.py'


for camera in ['scene_left', 'scene_right', 'wrist_left_plus', 'wrist_right_minus']:

    prefix = f'cv_webdatasets/LBM/buffer_buf[120_p16]-ctx[sequence-single]_cam[{camera}]_resi[256,368]'

    datasets = aws_s3_ls(f'{s3_path_east}/{prefix}')
    for dataset in datasets:
        for mode in ['tarfiles', 'indices']:
            command = f'{script} ' \
                    f'{s3_path_east}/{prefix}/{dataset}/{mode} ' \
                    f'{s3_path_west}/{prefix}/{dataset}/{mode} ' \
                    f'--num_proc 24 --verbose'
            os.system(command)



