Skip to content

Commit

Permalink
Merge pull request #12 from broadinstitute/breadbox-index-propery-fix
Browse files Browse the repository at this point in the history
fix(breadbox): prevent thrown exception when indexed property is missing
  • Loading branch information
pgm authored Jul 23, 2024
2 parents 920fb4f + b6db3ed commit 20cf3bb
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions breadbox/breadbox/crud/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,22 @@ def create_index_records_for_row(
db.query(Dataset).filter(Dataset.id == referenced_dataset_id).one()
)

if (
row.property_metadata[property].annotation_type
== AnnotationType.list_strings
):
values = cast_tabular_cell_value_type(
row.property_metadata[property].value,
row.property_metadata[property].annotation_type,
)
if property not in row.property_metadata:
# if the property doesn't exist, just skip it instead of throwing an exception
# This often happens when updating datasets because the properties to index
# will include a property which hasn't been uploaded yet.
continue
else:
values = [row.property_metadata[property].value]
if (
row.property_metadata[property].annotation_type
== AnnotationType.list_strings
):
values = cast_tabular_cell_value_type(
row.property_metadata[property].value,
row.property_metadata[property].annotation_type,
)
else:
values = [row.property_metadata[property].value]

assert isinstance(values, list)
parent_dimension_id = row.property_metadata[property].dimension_id
Expand Down

0 comments on commit 20cf3bb

Please sign in to comment.