Skip to content

Commit

Permalink
fixing weather download, adding backoff condition
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerket committed Apr 2, 2024
1 parent 92993de commit 21b6dcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions buildstockbatch/aws/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ def backoff(thefunc, *args, **kwargs):
backoff_mult = 1.1
delay = 3
tries = 5
error_patterns = [r"\w+.NotFound"]
error_patterns = [r"\w+.NotFound", r"not in VALID state"]
while tries > 0:
try:
result = thefunc(*args, **kwargs)
except ClientError as error:
error_code = error.response["Error"]["Code"]
error_msg = error.response["Error"]["Message"]
caught_error = False
for pat in error_patterns:
if re.search(pat, error_code):
if re.search(pat, error_code) or re.search(pat, error_msg):
logger.debug(f"{error_code}: Waiting and retrying in {delay} seconds")
caught_error = True
time.sleep(delay)
Expand Down
2 changes: 1 addition & 1 deletion buildstockbatch/cloud/docker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _epws_by_option(options_lookup_path):
"The epw files are specified in options_lookup.tsv under more than one parameter "
f"type: {param_name}, {row[0]}"
) # noqa: E501
epw_filename = row[row_has_epw.index(True) + 2].split("=")[1]
epw_filename = row[row_has_epw.index(True) + 2].split("=")[1].split("/")[-1]
param_name = row[0]
option_name = row[1]
epws_by_option[option_name] = epw_filename
Expand Down

0 comments on commit 21b6dcd

Please sign in to comment.