Skip to content

Commit

Permalink
Refrain from patching known-invalid fields (will fix source database …
Browse files Browse the repository at this point in the history
…instead)

This commit also includes a minor simplification to the `remove_id_pattern_constraints` function.
  • Loading branch information
eecavanna authored and dwinston committed Apr 19, 2024
1 parent ff1c7fb commit 53a1794
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
" Note: This algorithm was copied from the `without_id_patterns` function in `nmdc_runtime/util.py`.\n",
" \"\"\"\n",
" custom_schema = deepcopy(nmdc_schema)\n",
" for _, spec in custom_schema[\"$defs\"].items():\n",
" for spec in custom_schema[\"$defs\"].values():\n",
" if \"properties\" in spec and \"id\" in spec[\"properties\"] and \"pattern\" in spec[\"properties\"][\"id\"]:\n",
" del spec[\"properties\"][\"id\"][\"pattern\"]\n",
" return custom_schema\n",
Expand Down Expand Up @@ -437,12 +437,6 @@
" # Reference: https://docs.python.org/3/library/stdtypes.html#dict (see the \"type constructor\" section)\n",
" #\n",
" document_without_underscore_id_key = {key: value for key, value in document.items() if key != \"_id\"}\n",
" \n",
" # Patch documents that contain invalid data, while the team is figuring out how we'll handle these long term.\n",
" for field_name in [\"compression_type\", \"was_generated_by\"]:\n",
" if field_name in document_without_underscore_id_key and document_without_underscore_id_key[field_name] is None:\n",
" document_without_underscore_id_key[field_name] = \"\"\n",
"\n",
" root_to_validate = dict([(collection_name, [document_without_underscore_id_key])])\n",
" try:\n",
" nmdc_jsonschema_validator.validate(root_to_validate) # raises exception if invalid\n",
Expand Down

0 comments on commit 53a1794

Please sign in to comment.