Skip to content

Commit 8cbd939

Browse files
Update src/utils.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 44a2ebc commit 8cbd939

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/utils.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,30 @@ def default(self, o):
7373
mutate_self=False,
7474
)
7575
if isinstance(obj, Flight):
76-
try:
76+
if isinstance(obj, Flight):
77+
try:
78+
- evaluate_post_process = getattr(obj, '_Flight__evaluate_post_process', None)
7779
evaluate_post_process = getattr(obj, '_Flight__evaluate_post_process', None)
78-
79-
# Check if it's corrupted (numpy array instead of cached_property)
80-
if isinstance(evaluate_post_process, np.ndarray):
81-
try:
82-
delattr(obj, '_Flight__evaluate_post_process')
83-
84-
restored_method = getattr(obj, '_Flight__evaluate_post_process', None)
85-
if restored_method and callable(restored_method):
86-
restored_method()
87-
except Exception as fix_error:
88-
logger.error(f"Error fixing _Flight__evaluate_post_process: {fix_error}")
80+
81+
# Check if it's corrupted (numpy array instead of cached_property)
82+
if isinstance(evaluate_post_process, np.ndarray):
83+
try:
84+
delattr(obj, '_Flight__evaluate_post_process')
8985

90-
elif evaluate_post_process is not None and callable(evaluate_post_process):
91-
evaluate_post_process()
92-
93-
except (AttributeError, TypeError, ValueError) as e:
94-
logger.error(f"Error handling Flight object corruption: {e}")
95-
86+
restored_method = getattr(obj, '_Flight__evaluate_post_process', None)
87+
if restored_method and callable(restored_method):
88+
restored_method()
89+
- except Exception as fix_error:
90+
- logger.error(f"Error fixing _Flight__evaluate_post_process: {fix_error}")
91+
except (AttributeError, TypeError) as fix_error:
92+
logger.exception("Error fixing _Flight__evaluate_post_process")
93+
94+
elif evaluate_post_process is not None and callable(evaluate_post_process):
95+
evaluate_post_process()
96+
97+
except (AttributeError, TypeError, ValueError) as e:
98+
- logger.error(f"Error handling Flight object corruption: {e}")
99+
logger.exception("Error handling Flight object corruption")
96100
try:
97101
solution = np.array(obj.solution)
98102
except Exception as e:

0 commit comments

Comments
 (0)