def test_expand_relative_paths_in_launchers_config_using_command_line(self): local_config = {'models': [{ 'name': 'model', 'launchers': [{ 'framework': 'dlsdk', 'model': 'relative_model_path', 'weights': 'relative_weights_path', 'cpu_extensions': 'relative_extensions_path', 'gpu_extensions': 'relative_extensions_path', 'caffe_model': 'relative_model_path', 'caffe_weights': 'relative_weights_path', 'tf_model': 'relative_model_path', 'mxnet_weights': 'relative_weights_path', 'bitstream': 'relative_bitstreams_path' }] }]} expected = copy.deepcopy(local_config['models'][0]['launchers'][0]) expected['model'] = self.arguments.models / 'relative_model_path' expected['caffe_model'] = self.arguments.models / 'relative_model_path' expected['tf_model'] = self.arguments.models / 'relative_model_path' expected['weights'] = self.arguments.models / 'relative_weights_path' expected['caffe_weights'] = self.arguments.models / 'relative_weights_path' expected['mxnet_weights'] = self.arguments.models / 'relative_weights_path' expected['cpu_extensions'] = self.arguments.extensions / 'relative_extensions_path' expected['gpu_extensions'] = self.arguments.extensions / 'relative_extensions_path' expected['bitstream'] = self.arguments.bitstreams / 'relative_bitstreams_path' ConfigReader._merge_paths_with_prefixes(self.arguments, local_config) assert local_config['models'][0]['launchers'][0] == expected
def test_expand_relative_paths_in_datasets_config_using_command_line(self): local_config = { 'models': [{ 'name': 'model', 'datasets': [{ 'name': 'global_dataset', 'dataset_meta': 'relative_annotation_path', 'data_source': 'relative_source_path', 'segmentation_masks_source': 'relative_source_path', 'annotation': 'relative_annotation_path' }] }] } expected_dataset = copy.deepcopy( local_config['models'][0]['datasets'][0]) expected_dataset['annotation'] = self.merge( self.arguments.root, self.arguments.annotations, 'relative_annotation_path') expected_dataset['dataset_meta'] = self.merge( self.arguments.root, self.arguments.annotations, 'relative_annotation_path') expected_dataset['segmentation_masks_source'] = self.merge( self.arguments.root, self.arguments.source, 'relative_source_path') expected_dataset['data_source'] = self.merge(self.arguments.root, self.arguments.source, 'relative_source_path') ConfigReader._merge_paths_with_prefixes(self.arguments, local_config) assert local_config['models'][0]['datasets'][0] == expected_dataset
def test_not_modify_absolute_paths_in_datasets_config_using_command_line(self): local_config = {'models': [{ 'name': 'model', 'datasets': [{ 'name': 'global_dataset', 'dataset_meta': '/absolute_annotation_meta_path', 'data_source': '/absolute_source_path', 'annotation': '/absolute_annotation_path', }] }]} expected = copy.deepcopy(local_config['models'][0]['datasets'][0]) expected['annotation'] = Path('/absolute_annotation_path') expected['dataset_meta'] = Path('/absolute_annotation_meta_path') expected['data_source'] = Path('/absolute_source_path') ConfigReader._merge_paths_with_prefixes(self.arguments, local_config) assert local_config['models'][0]['datasets'][0] == expected