Skip to content

Commit

Permalink
Clarify log output from tangos write
Browse files Browse the repository at this point in the history
  • Loading branch information
apontzen committed Oct 8, 2023
1 parent d50f4b2 commit 3ed2c21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions tangos/cached_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ def create_property(halo, name, prop, session):

def _insert_list_unlocked(property_list):
session = core.get_default_session()

number = 0
for p in property_list:
if p[2] is not None:
session.add(create_property(p[0], p[1], p[2], session))
number += 1

session.commit()
return number

def insert_list(property_list):
from tangos import parallel_tasks as pt

if pt.backend!=None:
with pt.ExclusiveLock("insert_list"):
_insert_list_unlocked(property_list)
return _insert_list_unlocked(property_list)
else:
_insert_list_unlocked(property_list)
return _insert_list_unlocked(property_list)
12 changes: 7 additions & 5 deletions tangos/tools/property_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ def _is_commit_needed(self, end_of_timestep, end_of_simulation):
def _commit_results_if_needed(self, end_of_timestep=False, end_of_simulation=False):

if self._is_commit_needed(end_of_timestep, end_of_simulation):
logger.info("Attempting to commit %d halo properties...", len(self._pending_properties))
insert_list(self._pending_properties)
logger.info("%d properties were committed", len(self._pending_properties))
logger.info("Attempting to commit halo properties...")
num_properties = insert_list(self._pending_properties)
logger.info(f"...{num_properties} properties were committed")
self._pending_properties = []
self._start_time = time.time()
self.timing_monitor.summarise_timing(logger)
Expand Down Expand Up @@ -459,8 +459,10 @@ def run_timestep_calculation(self, db_timestep):

logger.info("Successfully gathered existing properties; calculating halo properties now...")

logger.info(" %d halos to consider; %d property calculations for each of them",
len(db_halos), len(self._property_calculator_instances))
logger.info(" %d halos to consider; %d calculation routines for each of them, resulting in %d properties per halo",
len(db_halos), len(self._property_calculator_instances),
sum([1 if isinstance(x.names, str) else len(x.names) for x in self._property_calculator_instances])
)

for db_halo, existing_properties in \
self._get_parallel_halo_iterator(list(zip(db_halos, self._existing_properties_all_halos))):
Expand Down

0 comments on commit 3ed2c21

Please sign in to comment.