Skip to content

Commit 5c0a254

Browse files
author
Michael McCrackan
committed
only add cols for first entry, fix typos
1 parent ff88c47 commit 5c0a254

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

sotodlib/site_pipeline/multilayer_preprocess_tod.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ def _main(executor: Union["MPICommExecutor", "ProcessPoolExecutor"],
411411

412412
total = len(futures)
413413

414+
add_obs_cols = True
414415
pb_name = f"pb_{str(int(time.time()))}.txt"
415416
with open(pb_name, 'w') as f:
416417
for future in tqdm(as_completed_callable(futures), total=total,
@@ -462,11 +463,13 @@ def _main(executor: Union["MPICommExecutor", "ProcessPoolExecutor"],
462463
else:
463464
j.jstate = JState.done
464465

465-
if (
466-
errors[0] is None
467-
and statsdb_path is not None
468-
and stats is not None
469-
):
466+
# update statsdb
467+
if (
468+
errors[0] is None
469+
and statsdb_path is not None
470+
and stats is not None
471+
):
472+
if add_obs_cols == True:
470473
stats_keys = []
471474
for k, v in stats.items():
472475
if isinstance(v, int):
@@ -475,8 +478,13 @@ def _main(executor: Union["MPICommExecutor", "ProcessPoolExecutor"],
475478
t = "float"
476479
elif isinstance(v, str):
477480
t = "string"
481+
478482
stats_keys.append(f"{k} {t}")
479483

484+
statsdb.add_obs_columns(stats_keys, ignore_duplicates=True)
485+
add_obs_cols = False
486+
statsdb.update_obs((obs_id, *group), stats)
487+
480488
if raise_error:
481489
n_obs_fail = 0
482490
n_groups_fail = 0

sotodlib/site_pipeline/preprocess_tod.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def _main(executor: Union["MPICommExecutor", "ProcessPoolExecutor"],
320320

321321
total = len(futures)
322322

323+
add_obs_cols = True
323324
pb_name = f"pb_{str(int(time.time()))}.txt"
324325
with open(pb_name, 'w') as f:
325326
for future in tqdm(as_completed_callable(futures), total=total,
@@ -361,22 +362,26 @@ def _main(executor: Union["MPICommExecutor", "ProcessPoolExecutor"],
361362
else:
362363
j.jstate = JState.done
363364

365+
# update statsdb
364366
if (
365367
errors[0] is None
366368
and statsdb_path is not None
367369
and stats is not None
368370
):
369-
stats_keys = []
370-
for k, v in stats.items():
371-
if isinstance(v, int):
372-
t = "int"
373-
elif isinstance(v, float):
374-
t = "float"
375-
elif isinstance(v, str):
376-
t = "string"
377-
stats_keys.append(f"{k} {t}")
378-
379-
statsdb.add_obs_columns(stats_keys, ignore_duplicates=True)
371+
if add_obs_cols == True:
372+
stats_keys = []
373+
for k, v in stats.items():
374+
if isinstance(v, int):
375+
t = "int"
376+
elif isinstance(v, float):
377+
t = "float"
378+
elif isinstance(v, str):
379+
t = "string"
380+
381+
stats_keys.append(f"{k} {t}")
382+
383+
statsdb.add_obs_columns(stats_keys, ignore_duplicates=True)
384+
add_obs_cols = False
380385
statsdb.update_obs((obs_id, *group), stats)
381386

382387
if raise_error:

0 commit comments

Comments
 (0)