Skip to content

Commit

Permalink
Exception fix (#236)
Browse files Browse the repository at this point in the history
Exception Handling while loading models.

Signed-off-by: kbatra <[email protected]>
  • Loading branch information
s0nicboOm authored Jul 28, 2023
1 parent 5a0ef08 commit e3f90db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions udf/anomaly-detection/src/udf/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def inference(
)
return static_response

except Exception as ex:
_LOGGER.exception(
"%s - Unhandled exception while fetching inference artifact, Keys: %s, Metric: %s, Error: %r",
payload.uuid,
payload.composite_keys,
payload.metrics,
ex,
)
return static_response

# Check if artifact is found
if not artifact_data:
_LOGGER.info(
Expand Down
10 changes: 10 additions & 0 deletions udf/anomaly-detection/src/udf/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ def preprocess(self, keys: List[str], payload: StreamPayload) -> (np.ndarray, St
)
return None, Status.RUNTIME_ERROR

except Exception as ex:
_LOGGER.exception(
"%s - Unhandled exception while fetching preproc artifact, Keys: %s, Metric: %s, Error: %r",
payload.uuid,
payload.composite_keys,
payload.metrics,
ex,
)
return None, Status.RUNTIME_ERROR

# Check if artifact is found
if not preproc_artifact:
_LOGGER.info(
Expand Down
11 changes: 11 additions & 0 deletions udf/anomaly-detection/src/udf/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ def threshold(
static_scores = calculate_static_thresh(metric_arr, static_thresh)
return static_scores, Status.RUNTIME_ERROR, Header.STATIC_INFERENCE, -1

except Exception as ex:
_LOGGER.exception(
"%s - Unhandled exception while fetching threshold artifact, Keys: %s, Metric: %s, Error: %r",
payload.uuid,
payload.composite_keys,
payload.metrics,
ex,
)
static_scores = calculate_static_thresh(metric_arr, static_thresh)
return static_scores, Status.RUNTIME_ERROR, Header.STATIC_INFERENCE, -1

# Check if artifact is found
if not thresh_artifact:
_LOGGER.info(
Expand Down

0 comments on commit e3f90db

Please sign in to comment.