Skip to content

Commit

Permalink
Merge pull request #537 from DagsHub/bug/annotation-get-blobs
Browse files Browse the repository at this point in the history
Bug: Don't try to parse annotations two times in a row
  • Loading branch information
kbolashev authored Oct 9, 2024
2 parents 6f5f950 + c76f0e6 commit c5aa94a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions dagshub/data_engine/model/query_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ def _convert_annotation_fields(self, *fields, load_into_memory):
for dp in self:
for fld in annotation_fields:
if fld in dp.metadata:
# Already loaded - skip
if isinstance(dp.metadata[fld], MetadataAnnotations):
continue
# Override the load_into_memory flag, because we need the contents
if not load_into_memory:
dp.metadata[fld] = Path(dp.metadata[fld]).read_bytes()
Expand All @@ -433,15 +436,16 @@ def _convert_annotation_fields(self, *fields, load_into_memory):
else:
dp.metadata[fld] = MetadataAnnotations(datapoint=dp, field=fld)

log_message(
"Warning: The following datapoints had invalid annotations, "
"any annotation-related operations will not work on these:"
)
err_msg = ""
for fld, dps in bad_annotations.items():
err_msg += f'Field "{fld}" in datapoints:\n\t'
err_msg += "\n\t".join(dps)
log_message(err_msg)
if bad_annotations:
log_message(
"Warning: The following datapoints had invalid annotations, "
"any annotation-related operations will not work on these:"
)
err_msg = ""
for fld, dps in bad_annotations.items():
err_msg += f'Field "{fld}" in datapoints:\n\t'
err_msg += "\n\t".join(dps)
log_message(err_msg)

def download_binary_columns(
self,
Expand Down

0 comments on commit c5aa94a

Please sign in to comment.