Skip to content

Commit

Permalink
Try 2 threading, mimicking existing style.
Browse files Browse the repository at this point in the history
  • Loading branch information
kburke committed Jun 25, 2024
1 parent b5aceac commit a94ace8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/hubmap_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ def _directly_modify_related_entities( self, es_url:str, es_index:str, entity_i
f" related_entity_target_elements={related_entity_target_elements}"
f" is not in es_index={es_index}.")

def _exec_reindex_entity_to_index_group_by_id(self, executor: concurrent.futures.ThreadPoolExecutor()
, entity_id: str(32), index_group: str):
def _exec_reindex_entity_to_index_group_by_id(self, entity_id: str(32), index_group: str):
logger.info(f"Start executing _exec_reindex_entity_to_index_group_by_id() on"
f" entity_id: {entity_id}, index_group: {index_group}")

entity = self.call_entity_api(entity_id=entity_id
, endpoint_base='documents')
executor.submit(self._transform_and_write_entity_to_index_group, entity, index_group)
self._transform_and_write_entity_to_index_group(entity=entity
, index_group=index_group)

logger.info(f"Finished executing _exec_reindex_entity_to_index_group_by_id()")

Expand Down Expand Up @@ -584,12 +584,10 @@ def translate(self, entity_id):

# Reindex the entity, and all related entities which have details of
# this entity in their document.
self._transform_and_write_entity_to_index_group(entity=entity
, index_group='portal')
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.submit(self._transform_and_write_entity_to_index_group, entity, 'portal')
for related_entity_uuid in target_ids:
self._exec_reindex_entity_to_index_group_by_id( executor=executor
, entity_id=related_entity_uuid
, index_group='portal')
futures_list = [executor.submit(self._exec_reindex_entity_to_index_group_by_id, related_entity_uuid, 'portal') for related_entity_uuid in target_ids]

logger.info(f"Finished executing translate() on {entity['entity_type']} of uuid: {entity_id}")
except Exception:
Expand Down

0 comments on commit a94ace8

Please sign in to comment.