Skip to content

Commit

Permalink
Merge pull request #90 from NASA-PDS/remove-temporary-repairkit-fix
Browse files Browse the repository at this point in the history
revert implementation of temporary repairkit fix
  • Loading branch information
alexdunnjpl authored Dec 14, 2023
2 parents 1614b42 + 4ea962a commit 3e3f620
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 61 deletions.
7 changes: 0 additions & 7 deletions src/pds/registrysweepers/repairkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ def function_name (document:{}, fieldname:str)->{}

log = logging.getLogger(__name__)

# TODO: remove me once applied to prod -- edunn 20231206
temporary_fix_targets = allarrays.EXCLUDED_PROPERTIES


def generate_updates(
docs: Iterable[Dict], repairkit_version_metadata_key: str, repairkit_version: int
Expand All @@ -73,10 +70,6 @@ def generate_updates(
for func in funcs:
repairs.update(func(src, fieldname))

# TODO: remove me once applied -- edunn 20231206
if fieldname in temporary_fix_targets:
repairs.update(allarrays.apply_reversion_fix(src, fieldname))

document_needed_fixing = len(set(repairs).difference({repairkit_version_metadata_key})) > 0
if document_needed_fixing and not repair_already_logged_to_error:
log.error(
Expand Down
12 changes: 0 additions & 12 deletions src/pds/registrysweepers/repairkit/allarrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,3 @@ def repair(document: Dict, fieldname: str) -> Dict:
log.debug(f"found string for {fieldname} where it should be an array")
return {fieldname: [document[fieldname]]}
return {}


# TODO: remove me once applied to prod -- edunn 20231206
def apply_reversion_fix(document: Dict, fieldname: str) -> Dict:
src_val = document[fieldname]
if isinstance(src_val, list) and len(src_val) == 1:
return {fieldname: src_val[0]}
else:
log.error(
f'Unexpected situation when applying reversion fix: Expected single-element array, got {src_val}, when targeting "{fieldname}" in {json.dumps(document)}'
)
return {}
42 changes: 0 additions & 42 deletions tests/pds/registrysweepers/repairkit/test_allarrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,6 @@ def test_exclusion_logic(self):

self.assertDictEqual({}, repairs, "test that excluded (string-typed) fields do not result in repair changes")

def test_temporary_reversion_fix(self):
# TODO: remove me once applied to prod -- edunn 20231206

src = {
"lid": ["urn:nasa:pds:clementine_lwir_bt:data_flatfield:ff034ag.img"],
"vid": ["1.0"],
"lidvid": ["urn:nasa:pds:clementine_lwir_bt:data_flatfield:ff034ag.img::1.0"],
"title": ["Clementine LWIR brightness temperature flat field product: ff034ag.img"],
"product_class": ["Product_Observational"],
"_package_id": ["c0491371-49f8-4e34-9d1c-f94ef1217b57"],
"someProperty": ["somePropertyValue"],
"ops:Provenance/ops:parent_collection_identifier": ["urn:nasa:pds:clementine_lwir_bt:data_flatfield::1.0"],
"ops:Provenance/ops:parent_bundle_identifier": ["urn:nasa:pds:clementine_lwir_bt::1.0"],
"ops:Provenance/ops:registry_sweepers_repairkit_version": 2,
}

expected = {
"lid": "urn:nasa:pds:clementine_lwir_bt:data_flatfield:ff034ag.img",
"vid": "1.0",
"lidvid": "urn:nasa:pds:clementine_lwir_bt:data_flatfield:ff034ag.img::1.0",
"title": "Clementine LWIR brightness temperature flat field product: ff034ag.img",
"product_class": "Product_Observational",
"_package_id": "c0491371-49f8-4e34-9d1c-f94ef1217b57",
"someProperty": ["somePropertyValue"],
"ops:Provenance/ops:parent_collection_identifier": ["urn:nasa:pds:clementine_lwir_bt:data_flatfield::1.0"],
"ops:Provenance/ops:parent_bundle_identifier": ["urn:nasa:pds:clementine_lwir_bt::1.0"],
"ops:Provenance/ops:registry_sweepers_repairkit_version": 2,
}

repairs = {}

for fieldname in src:
if fieldname in allarrays.EXCLUDED_PROPERTIES:
repairs.update(allarrays.apply_reversion_fix(src, fieldname))

src.update(repairs)
self.assertDictEqual(
expected,
src,
"test that enumerated string-typed fields are converted back to strings when reversion fix is applied",
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 3e3f620

Please sign in to comment.