Skip to content

Commit

Permalink
increases response timeout; minor refactor on importing statements; f…
Browse files Browse the repository at this point in the history
…ix parachute trigger evaluation context
  • Loading branch information
GabrielBarberini committed Sep 11, 2024
1 parent 568debc commit 3cf0b68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ RUN apt-get update && \

COPY ./lib /app/lib

CMD ["gunicorn", "-c", "lib/settings/gunicorn.py", "-w", "1", "--threads=2", "-k", "uvicorn.workers.UvicornWorker", "lib.api:app", "--log-level", "Debug", "-b", "0.0.0.0:3000", "--timeout", "35"]
CMD ["gunicorn", "-c", "lib/settings/gunicorn.py", "-w", "1", "--threads=2", "-k", "uvicorn.workers.UvicornWorker", "lib.api:app", "--log-level", "Debug", "-b", "0.0.0.0:3000", "--timeout", "60"]
16 changes: 9 additions & 7 deletions lib/services/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

from rocketpy.rocket.rocket import Rocket as RocketPyRocket
from rocketpy.rocket.parachute import Parachute as RocketPyParachute
from rocketpy.rocket.aero_surface import NoseCone as RocketPyNoseCone
from rocketpy.rocket.aero_surface import (
TrapezoidalFins as RocketPyTrapezoidalFins,
EllipticalFins as RocketPyEllipticalFins,
NoseCone as RocketPyNoseCone,
Fins as RocketPyFins,
Tail as RocketPyTail,
)
from rocketpy.rocket.aero_surface import Tail as RocketPyTail
from rocketpy.utilities import get_instance_attributes

from lib import logger
Expand Down Expand Up @@ -81,9 +81,11 @@ def from_rocket_model(cls, rocket: Rocket) -> Self:

# Parachutes
for parachute in rocket.parachutes:
if cls.check_parachute_trigger(parachute.trigger):
parachute.trigger = compile(
parachute.trigger, "<string>", "eval"
if cls.check_parachute_trigger(
trigger_expression := parachute.trigger
):
parachute.trigger = eval(# pylint: disable=eval-used
trigger_expression, {"__builtins__": None}, {}
)
rocketpy_parachute = cls.get_rocketpy_parachute(parachute)
rocketpy_rocket.parachutes.append(rocketpy_parachute)
Expand All @@ -100,7 +102,7 @@ def rocket(self) -> RocketPyRocket:
return self._rocket

@rocket.setter
def rocket(self, rocket: "RocketPyRocket"):
def rocket(self, rocket: RocketPyRocket):
self._rocket = rocket

def get_rocket_summary(self) -> RocketSummary:
Expand Down Expand Up @@ -217,7 +219,7 @@ def get_rocketpy_parachute(parachute: Parachute) -> RocketPyParachute:
rocketpy_parachute = RocketPyParachute(
name=parachute.name,
cd_s=parachute.cd_s,
trigger=eval(parachute.trigger), # pylint: disable=eval-used
trigger=parachute.trigger,
sampling_rate=parachute.sampling_rate,
lag=parachute.lag,
noise=parachute.noise,
Expand Down

0 comments on commit 3cf0b68

Please sign in to comment.