diff --git a/src/azul/plugins/metadata/anvil/__init__.py b/src/azul/plugins/metadata/anvil/__init__.py index aed275cad..02df4f6a3 100644 --- a/src/azul/plugins/metadata/anvil/__init__.py +++ b/src/azul/plugins/metadata/anvil/__init__.py @@ -222,7 +222,9 @@ def _field_mapping(self) -> MetadataPlugin._FieldMapping: ] }, # These field names are hard-coded in the implementation of - # the repository service/controller. + # the repository service/controller. Also, these field paths + # have a brittle coupling that must be maintained to the + # field lookups in `self.manifest_config`. **{ # Not in schema 'version': 'fileVersion', @@ -273,14 +275,12 @@ def facets(self) -> Sequence[str]: def manifest_config(self) -> ManifestConfig: result = defaultdict(dict) - # This is used to modify the field names from how they are specified in - # the field mapping. Keys are field paths in an ES hit, and values are - # the desired manifest column name, or None to omit the column from the - # manifest. - custom_field_names = { - ('contents', 'files', 'uuid'): None, - ('contents', 'files', 'version'): None, - } + # Note that there is a brittle coupling that must be maintained between + # the fields listed here and those used in `self._field_mapping`. + fields_to_omit_from_manifest = [ + ('contents', 'files', 'uuid'), + ('contents', 'files', 'version'), + ] def recurse(mapping: MetadataPlugin._FieldMapping, path: FieldPath): for path_element, name_or_type in mapping.items(): @@ -290,15 +290,16 @@ def recurse(mapping: MetadataPlugin._FieldMapping, path: FieldPath): elif isinstance(name_or_type, str): if new_path == ('entity_id',): pass - elif new_path in custom_field_names: - result[path][path_element] = custom_field_names.pop(new_path) + elif new_path in fields_to_omit_from_manifest: + result[path][path_element] = None + fields_to_omit_from_manifest.remove(new_path) else: result[path][path_element] = name_or_type else: assert False, (path, path_element, name_or_type) recurse(self._field_mapping, ()) - assert len(custom_field_names) == 0, custom_field_names + assert len(fields_to_omit_from_manifest) == 0, fields_to_omit_from_manifest # The file URL is synthesized from the `uuid` and `version` fields. # Above, we already configured these two fields to be omitted from the # manifest since they are not informative to the user.