Skip to content

Commit

Permalink
Refactor and document short-circuit for empty tallies (#6691)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Nov 21, 2024
1 parent e846402 commit 9e6fb98
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/azul/indexer/index_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ def index(self, catalog: CatalogName, bundle: Bundle) -> None:
for contributions, replicas in transforms:
tallies.update(self.contribute(catalog, contributions))
self.replicate(catalog, replicas)
if tallies:
self.aggregate(tallies)
self.aggregate(tallies)

def delete(self, catalog: CatalogName, bundle: Bundle) -> None:
"""
Expand Down Expand Up @@ -461,6 +460,12 @@ def aggregate(self, tallies: CataloguedTallies):
Also note that the input tallies can refer to entities from different
catalogs.
"""
# Attempting to filter by an empty array of coordinates while reading
# the aggregates will fail with a 400 error from ElasticSearch. This
# happens when indexing replica bundles for AnVIL, since they emit no
# contributions.
if not tallies:
return
# Use catalog specified in each tally
writer = self._create_writer(DocumentType.aggregate, catalog=None)
while True:
Expand Down

0 comments on commit 9e6fb98

Please sign in to comment.