@@ -77,11 +77,17 @@ def motor_kind(self) -> MotorKinds:
77
77
78
78
@flight .setter
79
79
def flight (self , flight : Flight ):
80
- self ._flight = flight
80
+ self ._flight = flight
81
81
82
82
@staticmethod
83
- async def get_rocketpy_flight (flight : Flight , rocket_option : RocketOptions , motor_kind : MotorKinds ) -> RocketPyFlight :
84
- rocketpy_rocket = RocketController .get_rocketpy_rocket (flight .rocket , rocket_option = rocket_option , motor_kind = motor_kind )
83
+ async def get_rocketpy_flight (flight : Flight ) -> RocketPyFlight :
84
+ """
85
+ Get the rocketpy flight object.
86
+
87
+ Returns:
88
+ RocketPyFlight
89
+ """
90
+ rocketpy_rocket = RocketController .get_rocketpy_rocket (flight .rocket )
85
91
rocketpy_env = EnvController .get_rocketpy_env (flight .environment )
86
92
rocketpy_flight = RocketPyFlight (
87
93
rocket = rocketpy_rocket ,
@@ -92,7 +98,6 @@ async def get_rocketpy_flight(flight: Flight, rocket_option: RocketOptions, moto
92
98
)
93
99
return rocketpy_flight
94
100
95
-
96
101
async def create_flight (self ) -> "Union[FlightCreated, HTTPException]" :
97
102
"""
98
103
Create a flight in the database.
@@ -121,12 +126,14 @@ async def create_flight(self) -> "Union[FlightCreated, HTTPException]":
121
126
)
122
127
123
128
@staticmethod
124
- async def get_flight_by_id (flight_id : str ) -> "Union[Flight, HTTPException]" :
129
+ async def get_flight_by_id (
130
+ flight_id : str ,
131
+ ) -> "Union[Flight, HTTPException]" :
125
132
"""
126
133
Get a flight from the database.
127
134
128
135
Args:
129
- flight_id: str
136
+ flight_id: str
130
137
131
138
Returns:
132
139
models.Flight
@@ -166,7 +173,7 @@ async def get_rocketpy_flight_as_jsonpickle(
166
173
Get rocketpy.flight as jsonpickle string.
167
174
168
175
Args:
169
- flight_id: str
176
+ flight_id: str
170
177
171
178
Returns:
172
179
views.FlightPickle
@@ -189,7 +196,7 @@ async def get_rocketpy_flight_as_jsonpickle(
189
196
) from e
190
197
else :
191
198
rocketpy_flight = await cls .get_rocketpy_flight (
192
- read_flight , read_flight . rocket . rocket_option , read_flight . rocket . motor . motor_kind
199
+ read_flight
193
200
)
194
201
return FlightPickle (
195
202
jsonpickle_rocketpy_flight = jsonpickle .encode (rocketpy_flight )
@@ -206,7 +213,7 @@ async def update_flight(
206
213
Update a flight in the database.
207
214
208
215
Args:
209
- flight_id: str
216
+ flight_id: str
210
217
211
218
Returns:
212
219
views.FlightUpdated
@@ -328,7 +335,7 @@ async def delete_flight(
328
335
Delete a flight from the database.
329
336
330
337
Args:
331
- flight_id: str
338
+ flight_id: str
332
339
333
340
Returns:
334
341
views.FlightDeleted
@@ -337,9 +344,7 @@ async def delete_flight(
337
344
HTTP 404 Not Found: If the flight is not found in the database.
338
345
"""
339
346
try :
340
- await FlightRepository (
341
- flight_id = flight_id
342
- ).delete_flight ()
347
+ await FlightRepository (flight_id = flight_id ).delete_flight ()
343
348
except HTTPException as e :
344
349
raise e from e
345
350
except Exception as e :
@@ -358,13 +363,14 @@ async def delete_flight(
358
363
359
364
@classmethod
360
365
async def simulate_flight (
361
- cls , flight_id : str ,
366
+ cls ,
367
+ flight_id : str ,
362
368
) -> "Union[FlightSummary, HTTPException]" :
363
369
"""
364
370
Simulate a rocket flight.
365
371
366
372
Args:
367
- flight_id: str
373
+ flight_id: str
368
374
369
375
Returns:
370
376
Flight summary view.
@@ -374,15 +380,7 @@ async def simulate_flight(
374
380
"""
375
381
try :
376
382
read_flight = await cls .get_flight_by_id (flight_id = flight_id )
377
- rocketpy_flight = cls .get_rocketpy_flight (
378
- flight = read_flight ,
379
- rocket_option = RocketOptions (
380
- read_flight .rocket .rocket_option
381
- ),
382
- motor_kind = MotorKinds (
383
- read_flight .rocket .motor .motor_kind
384
- )
385
- )
383
+ rocketpy_flight = cls .get_rocketpy_flight (flight = read_flight )
386
384
flight = rocketpy_flight
387
385
388
386
_initial_conditions = InitialConditions (
0 commit comments