Skip to content

Commit

Permalink
fix: Handle OCDS Merge exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jan 22, 2024
1 parent dc8632b commit 6119abd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions process/processors/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from process.util import create_note, get_or_create

logger = logging.getLogger(__name__)
format_string = "https://raw.githubusercontent.com/open-contracting-extensions/ocds_{}_extension/master/extension.json"


def save_compiled_release(merged, collection, ocid):
Expand All @@ -35,13 +36,8 @@ def compile_releases_by_ocdskit(collection, ocid, releases, extensions):
extensions = {extension.replace(":8443", "") for extension in extensions}

# The master version of the lots extension depends on OCDS 1.2 or the submission terms extension.
if (
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/master/extension.json"
in extensions
):
extensions.add(
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_submissionTerms_extension/master/extension.json" # noqa: E501
)
if format_string.format("lots") in extensions:
extensions.add(format_string.format("submissionTerms"))

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", category=ExtensionWarning)
Expand All @@ -51,7 +47,11 @@ def compile_releases_by_ocdskit(collection, ocid, releases, extensions):
if note := [str(warning.message) for warning in w if issubclass(warning.category, ExtensionWarning)]:
create_note(collection, CollectionNote.Level.WARNING, note)

return merger.create_compiled_release(releases)
try:
return merger.create_compiled_release(releases)
except ocdsmerge.exceptions.OCDSMergeError:
logger.exception("OCID %s can't be compiled, skipping", ocid)
create_note(collection, CollectionNote.Level.ERROR, f"OCID {ocid} can't be compiled")


@functools.lru_cache
Expand Down

0 comments on commit 6119abd

Please sign in to comment.