Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(xmlupload): misleading warning when uploading stashed XML texts (DEV-2793) #559

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 1 addition & 28 deletions src/dsp_tools/utils/xmlupload/upload_stashed_xml_texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,6 @@ def _log_unable_to_upload_xml_resource(
logger.warning(err_msg, exc_info=True)


def _log_iri_does_not_exist_error(
received_error: KeyError,
stashed_resource: XMLResource,
all_link_props: XMLProperty,
) -> None:
"""
This function logs if it is not possible to upload an XML resource
if a linked resource does not have an IRI in the triplestore.

Args:
received_error: Error received
stashed_resource: resource that is stashed
all_link_props: all the link properties from that resource
"""
err_msg = (
f"Unable to upload the xml text of '{all_link_props.name}' of resource '{stashed_resource.id}'"
f"because the resource with the internal id '{received_error.args[0]}' does not exist in the triplestore."
)
print(f" WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)


def _get_text_hash_value(old_xmltext: str) -> str:
"""
This function extracts the hash values in the text
Expand Down Expand Up @@ -203,12 +181,7 @@ def _upload_single_link_xml_property(
# this hash originates from _stash_circular_references(), and identifies the XML texts
try:
xml_from_stash = hash_to_value[text_hash_value]
except KeyError as err:
_log_iri_does_not_exist_error(
received_error=err,
stashed_resource=stashed_resource,
all_link_props=link_prop,
)
except KeyError:
# no action necessary: this property will remain in nonapplied_xml_texts,
# which will be handled by the caller
return nonapplied_xml_texts
Expand Down