Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/repositories/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def read_flight_by_id(self, flight_id: str) -> Optional[FlightModel]:
@repository_exception_handler
async def update_flight_by_id(self, flight_id: str, flight: FlightModel):
await self.update_by_id(
flight.model_dump(exclude_none=True), data_id=flight_id
flight.model_dump(exclude_none=False), data_id=flight_id
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@repository_exception_handler
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def read_motor_by_id(self, motor_id: str) -> Optional[MotorModel]:
@repository_exception_handler
async def update_motor_by_id(self, motor_id: str, motor: MotorModel):
await self.update_by_id(
motor.model_dump(exclude_none=True), data_id=motor_id
motor.model_dump(exclude_none=False), data_id=motor_id

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not able to initialise fields back to null om update

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because of some legacy rockets (e.g before drop null was deployed). Could you please test if this is also the case for rockets created after drop null was implemented?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested some old rockets and motors from April this year and null assignment is working fine for them. Not sure when this migration took place but it looks quite backward compatible.
If it breaks for any older than that, it might require some sort of backfill for them.

)

@repository_exception_handler
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def read_rocket_by_id(self, rocket_id: str) -> Optional[RocketModel]:
@repository_exception_handler
async def update_rocket_by_id(self, rocket_id: str, rocket: RocketModel):
await self.update_by_id(
rocket.model_dump(exclude_none=True), data_id=rocket_id
rocket.model_dump(exclude_none=False), data_id=rocket_id
)

@repository_exception_handler
Expand Down
30 changes: 28 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,34 @@ def default(self, o):
mutate_self=False,
)
if isinstance(obj, Flight):
obj._Flight__evaluate_post_process()
solution = np.array(obj.solution)
if isinstance(obj, Flight):
Comment thread
GabrielBarberini marked this conversation as resolved.
Outdated
try:
- evaluate_post_process = getattr(obj, '_Flight__evaluate_post_process', None)
evaluate_post_process = getattr(obj, '_Flight__evaluate_post_process', None)

# Check if it's corrupted (numpy array instead of cached_property)
if isinstance(evaluate_post_process, np.ndarray):
try:
delattr(obj, '_Flight__evaluate_post_process')

restored_method = getattr(obj, '_Flight__evaluate_post_process', None)
if restored_method and callable(restored_method):
restored_method()
- except Exception as fix_error:
- logger.error(f"Error fixing _Flight__evaluate_post_process: {fix_error}")
except (AttributeError, TypeError) as fix_error:
logger.exception("Error fixing _Flight__evaluate_post_process")
Comment thread
GabrielBarberini marked this conversation as resolved.
Outdated

elif evaluate_post_process is not None and callable(evaluate_post_process):
evaluate_post_process()

except (AttributeError, TypeError, ValueError) as e:
- logger.error(f"Error handling Flight object corruption: {e}")
logger.exception("Error handling Flight object corruption")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Comment thread
GabrielBarberini marked this conversation as resolved.
Outdated
try:
solution = np.array(obj.solution)
except (AttributeError, TypeError, ValueError):
return super().default(obj) # Fall back to parent encoder
Comment thread
GabrielBarberini marked this conversation as resolved.
Outdated
size = len(solution)
if size > 25:
reduction_factor = size // 25
Expand Down
Loading