Skip to content

Commit

Permalink
Up default maximum lookback window to 60 min. Better logging of why w…
Browse files Browse the repository at this point in the history
…e did not run.
  • Loading branch information
areeda committed Dec 18, 2023
1 parent d5ac9d0 commit 8954f5a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
25 changes: 15 additions & 10 deletions omicron/cli/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"""
import time

from omicron.utils import gps_to_hr
from omicron.utils import gps_to_hr, deltat_to_hr

prog_start = time.time()

Expand Down Expand Up @@ -276,7 +276,7 @@ def create_parser():
help='maximum number of channels to process in a single '
'condor job (default: %(default)s)',
)
procg.add_argument('--max-online-lookback', type=int, default=40 * 60,
procg.add_argument('--max-online-lookback', type=int, default=60 * 60,
help='With no immediately previous run, or one that was long ago this is the max time of an '
'online job. Default: %(default)d')
# max concurrent omicron jobs
Expand Down Expand Up @@ -733,12 +733,14 @@ def main(args=None):
segfile = str(rundir / "segments.txt")
keepfiles.append(segfile)
max_lookback = args.max_online_lookback
now = tconvert()

Check warning on line 736 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L735-L736

Added lines #L735 - L736 were not covered by tests

if newdag and online:
# get limit of available data (allowing for padding)
end = data.get_latest_data_gps(ifo, frametype) - padding
logger.info(f'Last available frame data: {gps_to_hr(end)}')
now = tconvert()
frame_age = deltat_to_hr(int(now - end))
logger.info(f'Last available frame data: {gps_to_hr(end)} age: frame_age')

Check warning on line 742 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L741-L742

Added lines #L741 - L742 were not covered by tests

earliest_online = now - max_lookback

Check warning on line 744 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L744

Added line #L744 was not covered by tests
try: # start from where we got to last time
last_run_segment = segments.get_last_run_segment(segfile)
Expand Down Expand Up @@ -783,8 +785,7 @@ def main(args=None):
dataduration = dataend - datastart

logger.info(f'Processing segment determined as: {gps_to_hr(datastart)} - {gps_to_hr(dataend)}')
dur_str = '{} {}'.format(int(dataduration / 86400) if dataduration > 86400 else '',
time.strftime('%H:%M:%S', time.gmtime(int(dataduration))))
dur_str = deltat_to_hr(dataduration)

Check warning on line 788 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L787-L788

Added lines #L787 - L788 were not covered by tests
logger.info(f"Duration = {dataduration} - {dur_str}")

span = (start, end)
Expand Down Expand Up @@ -996,10 +997,14 @@ def main(args=None):
trigsegs = type(segs)(type(s)(*s) for s in segs).contract(padding)

# display segments
logger.info("Final data segments selected as")
for seg in segs:
logger.info(f" {seg[0]:d} {seg[1]:d} {abs(seg):d}")
logger.info(f"Duration = {abs(segs):d} seconds")
if len(segs) == 0:
logger.info('No analyzable segments found. Exiting.')
exit(0)

Check warning on line 1002 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L1000-L1002

Added lines #L1000 - L1002 were not covered by tests
else:
logger.info("Final data segments selected as")
for seg in segs:
logger.info(f" {seg[0]:d} {seg[1]:d} {abs(seg):d}")
logger.info(f"Duration = {abs(segs):d} seconds")

Check warning on line 1007 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L1004-L1007

Added lines #L1004 - L1007 were not covered by tests

span = type(trigsegs)([trigsegs.extent()])

Expand Down
15 changes: 15 additions & 0 deletions omicron/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import os
import subprocess
import sys
import time
from pathlib import Path
from shutil import which
from tempfile import gettempdir
Expand Down Expand Up @@ -131,3 +132,17 @@ def gps_to_hr(gps):
dt_str = dt.strftime('%x %X')
ret = f'{int(gps)} ({dt_str})'
return ret

Check warning on line 134 in omicron/utils.py

View check run for this annotation

Codecov / codecov/patch

omicron/utils.py#L131-L134

Added lines #L131 - L134 were not covered by tests

def deltat_to_hr(dt):
"""
Convert a time in secos to human readable
@param int dt: delta t
@return str: <sec> [<day>] HH:MM:SS
"""
ret = f'{dt}'
if dt > 0:
day = f'{int(dt)/86400}' if dt >= 86400 else ''
time_str = time.strftime('%H:%M:%S', time.gmtime(int(dt)))
ret += ' - ' + time_str

Check warning on line 146 in omicron/utils.py

View check run for this annotation

Codecov / codecov/patch

omicron/utils.py#L142-L146

Added lines #L142 - L146 were not covered by tests

return ret

Check warning on line 148 in omicron/utils.py

View check run for this annotation

Codecov / codecov/patch

omicron/utils.py#L148

Added line #L148 was not covered by tests

0 comments on commit 8954f5a

Please sign in to comment.