Skip to content

Commit

Permalink
Per #2550, update tc_diag_driver code to version 0.6.1 from https://g…
Browse files Browse the repository at this point in the history
…ithub.com/robertdemariacira/tc_diag_driver to update the error handling logic.
  • Loading branch information
JohnHalleyGotway committed Oct 3, 2023
1 parent 1f7efd0 commit 547ffa4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/python/tc_diag/tc_diag_driver/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.0"
__version__ = "0.6.1"
14 changes: 10 additions & 4 deletions scripts/python/tc_diag/tc_diag_driver/computation_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@ def _compute_result(

# Result will either be a float or a Tuple of values if a
# computation produces multiple results at the same time.
result_tuple = None
try:
result_tuple = comp.computation(**all_args)
except KeyboardInterrupt:
raise
except:
except Exception as ex:
LOGGER.info(
"Encountered exception while running computation: %s at hour: %d with args: %s",
comp, forecast_hour, call_args)
"Encountered exception while running computation: %s at hour: %d",
comp.name, forecast_hour)
if not suppress_exceptions:
raise
msg = (f"Encountered error while running computation: "
f"{comp.name} at hour: {forecast_hour}")
raise Exception(msg).with_traceback(ex.__traceback__)

if result_tuple is None:
return

try:
len(result_tuple)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def main():

config = config_from_file(args.config_file, DriverConfig)

results = diag_calcs(config, args.data_file)
results = diag_calcs(
config, args.data_file, suppress_exceptions=args.suppress_exceptions)
if args.out_dir is not None:
_dump_results(results, args.out_dir)

Expand Down Expand Up @@ -83,6 +84,10 @@ def _get_args() -> argparse.Namespace:
type=pathlib.Path,
default=None,
help="Optional directory to write results to for debugging purposes.")
parser.add_argument("-s", "--suppress_exceptions", action="store_true",
default=False, help="If this flag is set, then "
"exceptions encountered during diagnostic computations "
"will be logged and then ignored.")

return parser.parse_args()

Expand Down

0 comments on commit 547ffa4

Please sign in to comment.