Commit b4b9c27c authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed incorrect handling of previously failed GMS_objects by exception_handler.

parent a3369bcd
Pipeline #1844 failed with stage
in 6 minutes
......@@ -36,7 +36,7 @@ def trace_unhandled_exceptions(func):
class ExceptionHandler(object):
def __init__(self, logger=None):
self.GMS_objs = None # type: Union[list, dict]
self.GMS_objs = None # type: Union[List[GMS_object], GMS_object, collections.OrderedDict, failed_GMS_object]
self.GMS_mapper_name = ''
self.GMS_mapper_failed = False
self._exc_details = None
......@@ -65,6 +65,7 @@ class ExceptionHandler(object):
@functools.wraps(GMS_mapper) # needed to avoid pickling errors
def wrapped_GMS_mapper(GMS_objs, **kwargs):
# type: (Union[List[GMS_object], GMS_object, collections.OrderedDict, failed_GMS_object], dict) -> any
"""
:param GMS_objs: one OR multiple instances of GMS_object or one instance of failed_object
......@@ -77,15 +78,24 @@ class ExceptionHandler(object):
# noinspection PyBroadException
try:
self.handle_previously_failed()
self.update_progress_started()
# GMS_mapper inputs CONTAIN NO failed_GMS_objects -> run the mapper normally
if not self.is_failed(self.GMS_objs):
self.update_progress_started()
# run the mapper function and store its results
self.GMS_objs = GMS_mapper(GMS_objs, **kwargs)
# run the mapper function and store its results
self.GMS_objs = GMS_mapper(GMS_objs, **kwargs)
self.increment_progress()
self.increment_progress()
return self.GMS_objs # type: Union[GMS_object, List[GMS_object]]
# GMS_mapper inputs CONTAIN failed_GMS_objects -> log and directly return failed_GMS_object
else:
GMS_obj = self.get_sample_GMS_obj(self.GMS_objs) # type: failed_GMS_object
print("Scene %s (entity ID %s) skipped %s due to an unexpected exception in %s."
% (GMS_obj.scene_ID, GMS_obj.entity_ID, self.GMS_mapper_name,
GMS_obj.failedMapper)) # TODO should be logged by PC.logger
self.GMS_objs = GMS_obj
return self.GMS_objs # type: Union[GMS_object, List[GMS_object], failed_GMS_object]
except OSError:
_, exc_val, _ = self.exc_details
......@@ -132,14 +142,6 @@ class ExceptionHandler(object):
GMS_objs if isinstance(GMS_objs, collections.OrderedDict) else \
GMS_objs[0] if isinstance(GMS_objs, (list, tuple)) else GMS_objs
def handle_previously_failed(self):
if self.is_failed(self.GMS_objs):
GMS_obj = self.get_sample_GMS_obj(self.GMS_objs) # type: failed_GMS_object
print("Scene %s (entity ID %s) skipped %s due to an unexpected exception in %s."
% (GMS_obj.scene_ID, GMS_obj.entity_ID, self.GMS_mapper_name,
GMS_obj.failedMapper)) # TODO should be logged by PC.logger
return self.GMS_objs
def update_progress_started(self):
"""in case of just initialized objects:
update statistics column in jobs table of postgreSQL database to 'started'"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment