Skip to content

Commit b7c897f

Browse files
fixes runtime issues
1 parent 583c37d commit b7c897f

File tree

9 files changed

+33
-18
lines changed

9 files changed

+33
-18
lines changed

lib/controllers/environment.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self):
2020
super().__init__(models=[EnvironmentModel])
2121

2222
@controller_exception_handler
23-
async def get_rocketpy_env_binary(
23+
async def get_rocketpy_environment_binary(
2424
self,
2525
env_id: str,
2626
) -> bytes:
@@ -36,8 +36,10 @@ async def get_rocketpy_env_binary(
3636
Raises:
3737
HTTP 404 Not Found: If the env is not found in the database.
3838
"""
39-
env = await self.get_environment_by_id(env_id)
40-
env_service = EnvironmentService.from_env_model(env)
39+
env_retrieved = await self.get_environment_by_id(env_id)
40+
env_service = EnvironmentService.from_env_model(
41+
env_retrieved.environment
42+
)
4143
return env_service.get_environment_binary()
4244

4345
@controller_exception_handler
@@ -56,6 +58,8 @@ async def get_environment_simulation(
5658
Raises:
5759
HTTP 404 Not Found: If the env does not exist in the database.
5860
"""
59-
env = await self.get_environment_by_id(env_id)
60-
env_service = EnvironmentService.from_env_model(env)
61+
env_retrieved = await self.get_environment_by_id(env_id)
62+
env_service = EnvironmentService.from_env_model(
63+
env_retrieved.environment
64+
)
6165
return env_service.get_environment_simulation()

lib/controllers/flight.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ async def get_rocketpy_flight_binary(
8282
Raises:
8383
HTTP 404 Not Found: If the flight is not found in the database.
8484
"""
85-
flight = await self.get_flight_by_id(flight_id)
86-
flight_service = FlightService.from_flight_model(flight)
85+
flight_retrieved = await self.get_flight_by_id(flight_id)
86+
flight_service = FlightService.from_flight_model(
87+
flight_retrieved.flight
88+
)
8789
return flight_service.get_flight_binary()
8890

8991
@controller_exception_handler
@@ -103,6 +105,8 @@ async def get_flight_simulation(
103105
Raises:
104106
HTTP 404 Not Found: If the flight does not exist in the database.
105107
"""
106-
flight = await self.get_flight_by_id(flight_id=flight_id)
107-
flight_service = FlightService.from_flight_model(flight)
108+
flight_retrieved = await self.get_flight_by_id(flight_id=flight_id)
109+
flight_service = FlightService.from_flight_model(
110+
flight_retrieved.flight
111+
)
108112
return flight_service.get_flight_simmulation()

lib/controllers/motor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ async def get_rocketpy_motor_binary(
3636
Raises:
3737
HTTP 404 Not Found: If the motor is not found in the database.
3838
"""
39-
motor = await self.get_motor_by_id(motor_id)
40-
motor_service = MotorService.from_motor_model(motor)
39+
motor_retrieved = await self.get_motor_by_id(motor_id)
40+
motor_service = MotorService.from_motor_model(motor_retrieved.motor)
4141
return motor_service.get_motor_binary()
4242

4343
@controller_exception_handler
@@ -54,6 +54,6 @@ async def get_motor_simulation(self, motor_id: str) -> MotorSimulation:
5454
Raises:
5555
HTTP 404 Not Found: If the motor does not exist in the database.
5656
"""
57-
motor = await self.get_motor_by_id(motor_id)
58-
motor_service = MotorService.from_motor_model(motor)
57+
motor_retrieved = await self.get_motor_by_id(motor_id)
58+
motor_service = MotorService.from_motor_model(motor_retrieved.motor)
5959
return motor_service.get_motor_simulation()

lib/controllers/rocket.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ async def get_rocketpy_rocket_binary(self, rocket_id: str) -> bytes:
3333
Raises:
3434
HTTP 404 Not Found: If the rocket is not found in the database.
3535
"""
36-
rocket = await self.get_rocket_by_id(rocket_id)
37-
rocket_service = RocketService.from_rocket_model(rocket)
36+
rocket_retrieved = await self.get_rocket_by_id(rocket_id)
37+
rocket_service = RocketService.from_rocket_model(
38+
rocket_retrieved.rocket
39+
)
3840
return rocket_service.get_rocket_binary()
3941

4042
@controller_exception_handler
@@ -54,6 +56,8 @@ async def get_rocket_simulation(
5456
Raises:
5557
HTTP 404 Not Found: If the rocket does not exist in the database.
5658
"""
57-
rocket = await self.get_rocket_by_id(rocket_id)
58-
rocket_service = RocketService.from_rocket_model(rocket)
59+
rocket_retrieved = await self.get_rocket_by_id(rocket_id)
60+
rocket_service = RocketService.from_rocket_model(
61+
rocket_retrieved.rocket
62+
)
5963
return rocket_service.get_rocket_simulation()

lib/models/interface.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
class ApiBaseModel(BaseModel, ABC):
1111
_id: Optional[str] = PrivateAttr(default=None)
1212
model_config = ConfigDict(
13-
extra="allow",
1413
use_enum_values=True,
1514
validate_default=True,
1615
validate_all_in_root=True,

lib/views/environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
class EnvironmentSimulation(ApiBaseView):
9+
message: str = "Environment successfully simulated"
910
latitude: Optional[float] = None
1011
longitude: Optional[float] = None
1112
elevation: Optional[float] = 1

lib/views/flight.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
class FlightSimulation(RocketSimulation, EnvironmentSimulation):
10+
message: str = "Flight successfully simulated"
1011
name: Optional[str] = None
1112
max_time: Optional[int] = None
1213
min_time_step: Optional[int] = None

lib/views/motor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
class MotorSimulation(BaseModel):
9+
message: str = "Motor successfully simulated"
910
average_thrust: Optional[float] = None
1011
burn_duration: Optional[float] = None
1112
burn_out_time: Optional[float] = None

lib/views/rocket.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
class RocketSimulation(MotorSimulation):
9+
message: str = "Rocket successfully simulated"
910
area: Optional[float] = None
1011
coordinate_system_orientation: str = 'tail_to_nose'
1112
center_of_mass_without_motor: Optional[float] = None

0 commit comments

Comments
 (0)