def test_infer_client(self): # HardDiskBackend file_client_args = {'backend': 'disk'} client = FileClient.infer_client(file_client_args) assert client.name == 'HardDiskBackend' client = FileClient.infer_client(uri=self.img_path) assert client.name == 'HardDiskBackend' # PetrelBackend file_client_args = {'backend': 'petrel'} client = FileClient.infer_client(file_client_args) assert client.name == 'PetrelBackend' uri = 's3://user_data' client = FileClient.infer_client(uri=uri) assert client.name == 'PetrelBackend'
def _find_samples(self): """find samples from ``data_prefix``.""" file_client = FileClient.infer_client(self.file_client_args, self.data_prefix) classes, folder_to_idx = find_folders(self.data_prefix, file_client) samples, empty_classes = get_samples( self.data_prefix, folder_to_idx, is_valid_file=self.is_valid_file, file_client=file_client, ) if len(samples) == 0: raise RuntimeError( f'Found 0 files in subfolders of: {self.data_prefix}. ' f'Supported extensions are: {",".join(self.extensions)}') if self.CLASSES is not None: assert len(self.CLASSES) == len(classes), \ f"The number of subfolders ({len(classes)}) doesn't match " \ f'the number of specified classes ({len(self.CLASSES)}). ' \ 'Please check the data folder.' else: self.CLASSES = classes if empty_classes: warnings.warn( 'Found no valid file in the folder ' f'{", ".join(empty_classes)}. ' f"Supported extensions are: {', '.join(self.extensions)}", UserWarning) self.folder_to_idx = folder_to_idx return samples