simonsobs / sotodlib

Simons Observatory: Time-Ordered Data processing library.
MIT License
16 stars 19 forks source link

G3HKDb error handling #698

Open kmharrington opened 9 months ago

kmharrington commented 9 months ago

We see this error a lot while running update-book-plan: https://prefect.simonsobs.org/flow-runs/flow-run/ce436902-324e-4aa1-90eb-9c717c9c733c. This should be handled better in data-packaging somehow.

File "/usr/local/lib/python3.10/site-packages/sotodlib/io/imprinter.py", line 1153, in update_bookdb_from_g3tsmurf
    final_time = SMURF.get_final_time(
  File "/usr/local/lib/python3.10/site-packages/sotodlib/io/load_smurf.py", line 1435, in get_final_time
    if stop > HK.get_last_update():
  File "/usr/local/lib/python3.10/site-packages/sotodlib/io/g3thk_db.py", line 534, in get_last_update
    return max([a.stop for a in last_file.agents])
ValueError: max() arg is an empty sequence
kmharrington commented 7 months ago

This and possibly some of the other HK errors look like they're happening when the HK database update is running. A db_file is commited first, then the agents/fields are updated. So if there are no agents in a file we should just go backwards in time to find agents.