def download_files(id, destination): """Download files of data""" api = rest.DataApi(configuration.get_api_client()) result = api.list_data_files(id, with_url=True) pool_manager = api.api_client.rest_client.pool_manager for x in result: object_storage.download_file(pool_manager, x.url, destination, x.file_name)
def download_files(id, file_id, destination): """Download files of training""" api = rest.TrainingApi(configuration.get_api_client()) result = api.list_training_files(id, with_url=True) pool_manager = api.api_client.rest_client.pool_manager for x in result: if not file_id or x.file_id in file_id: object_storage.download_file(pool_manager, x.url, destination, x.file_name)
def download_files(id, destination, data_type): """Download files of a dataset""" api = rest.DataSetApi(configuration.get_api_client()) result = api.list_dataset_files(id, with_url=True) pool_manager = api.api_client.rest_client.pool_manager for entry in result.entries: if not data_type or entry.type in data_type: for file in entry.files: destination_dir_path = os.path.join(destination, entry.type, str(file.id)) object_storage.download_file(pool_manager, file.url, destination_dir_path, file.file_name)
def download_entries(path): result = api.list_inference_container_files(id, path=path, with_url=True) for x in result.files: if os.path.isabs(path): _, tail = os.path.splitdrive(path) object_storage.download_file(pool_manager, x.url, destination + tail, x.file_name) else: object_storage.download_file(pool_manager, x.url, os.path.join(destination, path), x.file_name) for x in result.dirs: download_entries(os.path.join(path, x.dir_name))