Add traceback for failing to load preprocess class (#57)

This commit is contained in:
allegroai 2023-09-23 17:35:21 +03:00
parent 4a737b95c6
commit e4c07c756a

View File

@ -1,6 +1,7 @@
import os import os
import sys import sys
import threading import threading
import traceback
from pathlib import Path from pathlib import Path
from typing import Optional, Any, Callable, List from typing import Optional, Any, Callable, List
@ -48,8 +49,8 @@ class BasePreprocessRequest(object):
try: try:
self._instantiate_custom_preprocess_cls(task) self._instantiate_custom_preprocess_cls(task)
except Exception as ex: except Exception as ex:
raise ValueError("Error: Failed loading preprocess code for \'{}\': {}".format( raise ValueError("Error: Failed loading preprocess code for \'{}\': {}\n\n{}".format(
self.model_endpoint.preprocess_artifact, ex)) self.model_endpoint.preprocess_artifact, ex, traceback.format_exc()))
def _instantiate_custom_preprocess_cls(self, task: Task) -> None: def _instantiate_custom_preprocess_cls(self, task: Task) -> None:
path = task.artifacts[self.model_endpoint.preprocess_artifact].get_local_copy(extract_archive=False) path = task.artifacts[self.model_endpoint.preprocess_artifact].get_local_copy(extract_archive=False)