def _create_drive_folder(): return concat( progress( default_message='Creating Google Drive download folder...', message_key= 'tasks.retrieve.time_series_to_sepal.creating_drive_folder'), create_folder_with_path(credentials, drive_folder_path).pipe( flat_map(lambda _: empty())))
def _export_and_download_dates(stack, export_description, year_dir): table_drive_description = 'dates_' + export_description dates_drive_folder = '{}-{}'.format(table_drive_description, str(uuid.uuid4())) dates_drive_path = '{}/{}'.format(drive_folder_path, dates_drive_folder) create_dates_drive_folder = create_folder_with_path( credentials, dates_drive_path).pipe(flat_map(lambda _: empty())) export_dates = _export_dates(stack.bandNames(), table_drive_description, dates_drive_folder) download_dates_from_drive = _download_from_drive( path=dates_drive_path, destination=year_dir).pipe( map(lambda p: {'dates_bytes': p.downloaded_bytes})) return concat(create_dates_drive_folder, export_dates, download_dates_from_drive)
def _export_and_download_stack(stack, export_description, year_dir): stack_drive_description = 'stack_' + export_description stack_drive_folder = '{}-{}'.format(stack_drive_description, str(uuid.uuid4())) stack_drive_path = '{}/{}'.format(drive_folder_path, stack_drive_folder) create_stack_drive_folder = create_folder_with_path( credentials, stack_drive_path).pipe(flat_map(lambda _: empty())) export_stack = _export_stack(stack, stack_drive_description, stack_drive_folder).pipe( flat_map(lambda _: empty())) download_stack_from_drive = _download_from_drive( path=stack_drive_path, destination=year_dir).pipe( map(lambda p: {'stack_bytes': p.downloaded_bytes})) return concat( create_stack_drive_folder, export_stack, of({'exported': 1}), download_stack_from_drive, of({'downloaded': 1}), )