Skip to content

Commit 7e4c8c2

Browse files
aasitvora99GabrielBarberinicoderabbitai[bot]
authored
BUG: issues with encoding and null field updates (#60)
Co-authored-by: Gabriel Barberini <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 971f7ac commit 7e4c8c2

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pymongo
99
jsonpickle
1010
gunicorn
1111
uvicorn
12-
rocketpy
12+
git+https://github.com/RocketPy-Team/RocketPy.git@develop
1313
uptrace
1414
opentelemetry.instrumentation.fastapi
1515
opentelemetry.instrumentation.requests

src/repositories/motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def read_motor_by_id(self, motor_id: str) -> Optional[MotorModel]:
2828
@repository_exception_handler
2929
async def update_motor_by_id(self, motor_id: str, motor: MotorModel):
3030
await self.update_by_id(
31-
motor.model_dump(exclude_none=True), data_id=motor_id
31+
motor.model_dump(exclude_none=False), data_id=motor_id
3232
)
3333

3434
@repository_exception_handler

src/repositories/rocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def read_rocket_by_id(self, rocket_id: str) -> Optional[RocketModel]:
2828
@repository_exception_handler
2929
async def update_rocket_by_id(self, rocket_id: str, rocket: RocketModel):
3030
await self.update_by_id(
31-
rocket.model_dump(exclude_none=True), data_id=rocket_id
31+
rocket.model_dump(exclude_none=False), data_id=rocket_id
3232
)
3333

3434
@repository_exception_handler

src/utils.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,28 @@ def for_flight(cls) -> 'DiscretizeConfig':
5555

5656
class InfinityEncoder(RocketPyEncoder):
5757
def default(self, o):
58-
obj = o
5958
if (
60-
isinstance(obj, Function)
61-
and not callable(obj.source)
62-
and obj.__dom_dim__ == 1
59+
isinstance(o, Function)
60+
and not callable(o.source)
61+
and o.__dom_dim__ == 1
6362
):
64-
size = len(obj._domain)
63+
size = len(o._domain)
6564
reduction_factor = 1
6665
if size > 25:
6766
reduction_factor = size // 25
6867
if reduction_factor > 1:
69-
obj = obj.set_discrete(
70-
obj.x_array[0],
71-
obj.x_array[-1],
68+
o = o.set_discrete(
69+
o.x_array[0],
70+
o.x_array[-1],
7271
size // reduction_factor,
7372
mutate_self=False,
7473
)
75-
if isinstance(obj, Flight):
76-
obj._Flight__evaluate_post_process()
77-
solution = np.array(obj.solution)
74+
if isinstance(o, Flight):
75+
try:
76+
o._Flight__evaluate_post_process
77+
except Exception:
78+
pass
79+
solution = np.array(o.solution)
7880
size = len(solution)
7981
if size > 25:
8082
reduction_factor = size // 25
@@ -88,12 +90,12 @@ def default(self, o):
8890
reduced_solution[:, i] = interp1d(
8991
solution[:, 0], col, assume_sorted=True
9092
)(reduced_scale)
91-
obj.solution = reduced_solution.tolist()
93+
o.solution = reduced_solution.tolist()
9294

93-
obj.flight_phases = None
94-
obj.function_evaluations = None
95+
o.flight_phases = None
96+
o.function_evaluations = None
9597

96-
return super().default(obj)
98+
return super().default(o)
9799

98100

99101
def rocketpy_encoder(obj):

src/views/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class EnvironmentSimulation(ApiBaseView):
4343
initial_east: Optional[float] = None
4444
initial_hemisphere: Optional[str] = None
4545
initial_ew: Optional[str] = None
46-
max_expected_height: Optional[int] = None
46+
max_expected_height: Optional[float] = None
4747
date: Optional[datetime] = Field(default_factory=_default_future_datetime)
4848
local_date: Optional[datetime] = Field(
4949
default_factory=_default_future_datetime

0 commit comments

Comments
 (0)