Skip to content

Commit

Permalink
removes forward reference and improves logs wording
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBarberini committed May 20, 2024
1 parent c02b505 commit 873f96e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 40 deletions.
26 changes: 14 additions & 12 deletions lib/controllers/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def get_rocketpy_env(env: Env) -> RocketPyEnvironment:
)
return rocketpy_env

async def create_env(self) -> "Union[EnvCreated, HTTPException]":
async def create_env(self) -> Union[EnvCreated, HTTPException]:
"""
Create a env in the database.
Expand All @@ -84,11 +84,11 @@ async def create_env(self) -> "Union[EnvCreated, HTTPException]":
return EnvCreated(env_id=created_env.env_id)
finally:
logger.info(
f"Call to controllers.environment.create_env completed; params: Env {hash(self.env)}"
f"Call to controllers.environment.create_env completed for Env {hash(self.env)}"
)

@staticmethod
async def get_env_by_id(env_id: str) -> "Union[Env, HTTPException]":
async def get_env_by_id(env_id: str) -> Union[Env, HTTPException]:
"""
Get a env from the database.
Expand Down Expand Up @@ -119,14 +119,14 @@ async def get_env_by_id(env_id: str) -> "Union[Env, HTTPException]":
)
finally:
logger.info(
f"Call to controllers.environment.get_env_by_id completed; params: EnvID {env_id}"
f"Call to controllers.environment.get_env_by_id completed for Env {env_id}"
)

@classmethod
async def get_rocketpy_env_as_jsonpickle(
cls,
env_id: str,
) -> "Union[EnvPickle, HTTPException]":
) -> Union[EnvPickle, HTTPException]:
"""
Get rocketpy.Environmnet as jsonpickle string.
Expand Down Expand Up @@ -159,12 +159,12 @@ async def get_rocketpy_env_as_jsonpickle(
)
finally:
logger.info(
f"Call to controllers.environment.get_rocketpy_env_as_jsonpickle completed; params: EnvID {env_id}"
f"Call to controllers.environment.get_rocketpy_env_as_jsonpickle completed for Env {env_id}"
)

async def update_env(
self, env_id: str
) -> "Union[EnvUpdated, HTTPException]":
) -> Union[EnvUpdated, HTTPException]:
"""
Update a env in the database.
Expand Down Expand Up @@ -195,11 +195,11 @@ async def update_env(
return EnvUpdated(new_env_id=updated_env.env_id)
finally:
logger.info(
f"Call to controllers.environment.update_env completed; params: EnvID {env_id}, Env {hash(self.env)}"
f"Call to controllers.environment.update_env completed for Env {env_id}; Env {hash(self.env)}"
)

@staticmethod
async def delete_env(env_id: str) -> "Union[EnvDeleted, HTTPException]":
async def delete_env(env_id: str) -> Union[EnvDeleted, HTTPException]:
"""
Delete a env from the database.
Expand All @@ -225,11 +225,13 @@ async def delete_env(env_id: str) -> "Union[EnvDeleted, HTTPException]":
return EnvDeleted(deleted_env_id=env_id)
finally:
logger.info(
f"Call to controllers.environment.delete_env completed; params: EnvID {env_id}"
f"Call to controllers.environment.delete_env completed for Env {env_id}"
)

@classmethod
async def simulate(cls, env_id: str) -> "Union[EnvSummary, HTTPException]":
async def simulate_env(
cls, env_id: str
) -> Union[EnvSummary, HTTPException]:
"""
Simulate a rocket environment.
Expand Down Expand Up @@ -267,5 +269,5 @@ async def simulate(cls, env_id: str) -> "Union[EnvSummary, HTTPException]":
return env_summary
finally:
logger.info(
f"Call to controllers.environment.simulate completed; params: EnvID {env_id}"
f"Call to controllers.environment.simulate completed for Env {env_id}"
)
32 changes: 16 additions & 16 deletions lib/controllers/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def get_rocketpy_flight(flight: Flight) -> RocketPyFlight:
)
return rocketpy_flight

async def create_flight(self) -> "Union[FlightCreated, HTTPException]":
async def create_flight(self) -> Union[FlightCreated, HTTPException]:
"""
Create a flight in the database.
Expand All @@ -122,13 +122,13 @@ async def create_flight(self) -> "Union[FlightCreated, HTTPException]":
return FlightCreated(flight_id=str(created_flight.flight_id))
finally:
logger.info(
f"Call to controllers.flight.create_flight completed; params: Flight {hash(self.flight)}"
f"Call to controllers.flight.create_flight completed for Flight {hash(self.flight)}"
)

@staticmethod
async def get_flight_by_id(
flight_id: str,
) -> "Union[Flight, HTTPException]":
) -> Union[Flight, HTTPException]:
"""
Get a flight from the database.
Expand Down Expand Up @@ -161,14 +161,14 @@ async def get_flight_by_id(
) from e
finally:
logger.info(
f"Call to controllers.flight.get_flight_by_id completed; params: FlightID {flight_id}"
f"Call to controllers.flight.get_flight_by_id completed for Flight {flight_id}"
)

@classmethod
async def get_rocketpy_flight_as_jsonpickle(
cls,
flight_id: str,
) -> "Union[FlightPickle, HTTPException]":
) -> Union[FlightPickle, HTTPException]:
"""
Get rocketpy.flight as jsonpickle string.
Expand Down Expand Up @@ -201,12 +201,12 @@ async def get_rocketpy_flight_as_jsonpickle(
)
finally:
logger.info(
f"Call to controllers.flight.get_rocketpy_flight_as_jsonpickle completed; params: FlightID {flight_id}"
f"Call to controllers.flight.get_rocketpy_flight_as_jsonpickle completed for Flight {flight_id}"
)

async def update_flight(
self, flight_id: str
) -> "Union[FlightUpdated, HTTPException]":
) -> Union[FlightUpdated, HTTPException]:
"""
Update a flight in the database.
Expand Down Expand Up @@ -237,13 +237,13 @@ async def update_flight(
return FlightUpdated(new_flight_id=str(updated_flight.flight_id))
finally:
logger.info(
f"Call to controllers.flight.update_flight completed; params: FlightID {flight_id}"
f"Call to controllers.flight.update_flight completed for Flight {flight_id}"
)

@classmethod
async def update_env(
cls, flight_id: str, env: Env
) -> "Union[FlightUpdated, HTTPException]":
) -> Union[FlightUpdated, HTTPException]:
"""
Update the environment of a flight in the database.
Expand Down Expand Up @@ -278,13 +278,13 @@ async def update_env(
return FlightUpdated(new_flight_id=str(updated_flight.flight_id))
finally:
logger.info(
f"Call to controllers.flight.update_env completed; params: FlightID {flight_id}, Env {hash(env)}"
f"Call to controllers.flight.update_env completed for Flight {flight_id}; Env {hash(env)}"
)

@staticmethod
async def update_rocket(
flight_id: str, rocket: Rocket, rocket_option, motor_kind
) -> "Union[FlightUpdated, HTTPException]":
) -> Union[FlightUpdated, HTTPException]:
"""
Update the rocket of a flight in the database.
Expand Down Expand Up @@ -322,13 +322,13 @@ async def update_rocket(
return FlightUpdated(new_flight_id=str(new_flight_id))
finally:
logger.info(
f"Call to controllers.flight.update_rocket completed; params: FlightID {flight_id}, Rocket {hash(rocket)}"
f"Call to controllers.flight.update_rocket completed for Flight {flight_id}; Rocket {hash(rocket)}"
)

@staticmethod
async def delete_flight(
flight_id: str,
) -> "Union[FlightDeleted, HTTPException]":
) -> Union[FlightDeleted, HTTPException]:
"""
Delete a flight from the database.
Expand Down Expand Up @@ -356,14 +356,14 @@ async def delete_flight(
return FlightDeleted(deleted_flight_id=str(flight_id))
finally:
logger.info(
f"Call to controllers.flight.delete_flight completed; params: FlightID {flight_id}"
f"Call to controllers.flight.delete_flight completed for Flight {flight_id}"
)

@classmethod
async def simulate_flight(
cls,
flight_id: str,
) -> "Union[FlightSummary, HTTPException]":
) -> Union[FlightSummary, HTTPException]:
"""
Simulate a rocket flight.
Expand Down Expand Up @@ -643,5 +643,5 @@ async def simulate_flight(
return flight_summary
finally:
logger.info(
f"Call to controllers.flight.simulate_flight completed; params: FlightID {flight_id}"
f"Call to controllers.flight.simulate_flight completed for Flight {flight_id}"
)
24 changes: 12 additions & 12 deletions lib/controllers/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_rocketpy_rocket(cls, rocket: Rocket) -> RocketPyRocket:

return rocketpy_rocket

async def create_rocket(self) -> "Union[RocketCreated, HTTPException]":
async def create_rocket(self) -> Union[RocketCreated, HTTPException]:
"""
Create a rocket in the database.
Expand All @@ -156,13 +156,13 @@ async def create_rocket(self) -> "Union[RocketCreated, HTTPException]":
return RocketCreated(rocket_id=str(created_rocket.rocket_id))
finally:
logger.info(
f"Call to controllers.rocket.create_rocket completed; params: Rocket {hash(self.rocket)}"
f"Call to controllers.rocket.create_rocket completed for Rocket {hash(self.rocket)}"
)

@staticmethod
async def get_rocket_by_id(
rocket_id: str,
) -> "Union[Rocket, HTTPException]":
) -> Union[Rocket, HTTPException]:
"""
Get a rocket from the database.
Expand Down Expand Up @@ -195,13 +195,13 @@ async def get_rocket_by_id(
)
finally:
logger.info(
f"Call to controllers.rocket.get_rocket_by_id completed; params: RocketID {rocket_id}"
f"Call to controllers.rocket.get_rocket_by_id completed for Rocket {rocket_id}"
)

@classmethod
async def get_rocketpy_rocket_as_jsonpickle(
cls, rocket_id: str
) -> "Union[RocketPickle, HTTPException]":
) -> Union[RocketPickle, HTTPException]:
"""
Get a rocketpy.Rocket object as jsonpickle string.
Expand Down Expand Up @@ -234,12 +234,12 @@ async def get_rocketpy_rocket_as_jsonpickle(
)
finally:
logger.info(
f"Call to controllers.rocket.get_rocketpy_rocket_as_jsonpickle completed; params: RocketID {rocket_id}"
f"Call to controllers.rocket.get_rocketpy_rocket_as_jsonpickle completed for Rocket {rocket_id}"
)

async def update_rocket(
self, rocket_id: str
) -> "Union[RocketUpdated, HTTPException]":
) -> Union[RocketUpdated, HTTPException]:
"""
Update a rocket in the database.
Expand Down Expand Up @@ -270,13 +270,13 @@ async def update_rocket(
return RocketUpdated(new_rocket_id=str(updated_rocket.rocket_id))
finally:
logger.info(
f"Call to controllers.rocket.update_rocket completed; params: RocketID {rocket_id}"
f"Call to controllers.rocket.update_rocket completed for Rocket {rocket_id}"
)

@staticmethod
async def delete_rocket(
rocket_id: str,
) -> "Union[RocketDeleted, HTTPException]":
) -> Union[RocketDeleted, HTTPException]:
"""
Delete a rocket from the database.
Expand All @@ -302,14 +302,14 @@ async def delete_rocket(
return RocketDeleted(deleted_rocket_id=str(rocket_id))
finally:
logger.info(
f"Call to controllers.rocket.delete_rocket completed; params: RocketID {rocket_id}"
f"Call to controllers.rocket.delete_rocket completed for Rocket {rocket_id}"
)

@classmethod
async def simulate(
cls,
rocket_id: str,
) -> "Union[RocketSummary, HTTPException]":
) -> Union[RocketSummary, HTTPException]:
"""
Simulate a rocket rocket.
Expand Down Expand Up @@ -477,7 +477,7 @@ async def simulate(
return rocket_summary
finally:
logger.info(
f"Call to controllers.rocket.simulate completed; params: RocketID {rocket_id}"
f"Call to controllers.rocket.simulate completed for Rocket {rocket_id}"
)

@staticmethod
Expand Down

0 comments on commit 873f96e

Please sign in to comment.