Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpus committed Mar 13, 2022
2 parents 426b506 + 5dc1f9f commit e9dbb41
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
5 changes: 3 additions & 2 deletions eht_met_forecast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ def main(args=None):
stats['elapsed_wait_s'] = elapsed
else:
stats['elapsed_s'] = elapsed
dump_stats(stats, log=args.log)
dump_latency_histograms(log=args.log)
if elapsed > 0:
dump_stats(stats, log=args.log)
dump_latency_histograms(log=args.log)

if exit_value:
exit(exit_value)
26 changes: 16 additions & 10 deletions eht_met_forecast/gfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def fetch_gfs_download(url, params, wait=False, verbose=False, stats=None):

retry = MAX_DOWNLOAD_TRIES
actual_tries = 0
quiet_retry = False
r = None # so we can use it even after an exception
while retry > 0:
try:
Expand Down Expand Up @@ -164,7 +165,11 @@ def fetch_gfs_download(url, params, wait=False, verbose=False, stats=None):
# HTTP/1.1 302 Your allowed limit has been reached. Please go to https://www.weather.gov/abusive-user-block for more info
# This 302 does not have a Location: header, so we test for it to make it less likely we'll end up in an infinite loop
errflag = 1
print('Received retryable status ({})'.format(r.status_code), file=sys.stderr, end='')
if actual_tries > 1:
# this happens ~ 33 times per run (out of 209) so make it quieter
print('Received retryable status ({})'.format(r.status_code), file=sys.stderr, end='')
else:
quiet_retry = True
retry += 1 # free retry
retry_duration = jiggle(RATELIMIT_DELAY)
if stats:
Expand Down Expand Up @@ -214,17 +219,18 @@ def fetch_gfs_download(url, params, wait=False, verbose=False, stats=None):
stats['exception_'+str(e)] += 1

if errflag:
if actual_tries > 1:
print(' tries={}'.format(actual_tries), file=sys.stderr, end='')
retry = retry - 1
if retry > 0:
print(" Retrying...", file=sys.stderr)
if r:
try: # I don't think this can fail, but anyway
if len(r.content):
print(' Content was:', r.content[:100])
except Exception:
pass
if not quiet_retry:
print(' tries={}'.format(actual_tries), file=sys.stderr, end='')
print(" Retrying...", file=sys.stderr)
if r:
try: # I don't think this can fail, but anyway
content = r.content[:100]
if content:
print(' Content was:', content, file=sys.stderr)
except Exception:
pass
time.sleep(retry_duration)
else:
print(" Giving up.", file=sys.stderr)
Expand Down
3 changes: 2 additions & 1 deletion scripts/lindy.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def xyz2loc(xyz):
try:
stations = set(c[0].replace('Ax', 'Aa').replace('Mm', 'Sw') for c in b['station'])
except IndexError:
stations = set(b['station'][0].replace('Ax', 'Aa').replace('Mm', 'Sw'))
# when there is only 1 station in a scan, the data structure is just a list instead of a list of lists
stations = {b['station'][0].replace('Ax', 'Aa').replace('Mm', 'Sw')}
try:
taus = np.array([allint[s][gfs_cycle](dtimes) for s in stations])
except KeyError:
Expand Down

0 comments on commit e9dbb41

Please sign in to comment.