better error handling
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m2s
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 58s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 23s

This commit is contained in:
2025-01-28 13:04:42 +01:00
parent b527318eec
commit 25c2b6b0d1
4 changed files with 17 additions and 11 deletions

View File

@@ -40,7 +40,8 @@ app = FastAPI(lifespan=lifespan)
@app.post("/trip/new")
def new_trip(preferences: Preferences,
start: tuple[float, float],
end: tuple[float, float] | None = None) -> Trip:
end: tuple[float, float] | None = None,
background_tasks: BackgroundTasks = None) -> Trip:
"""
Main function to call the optimizer.
@@ -135,7 +136,7 @@ def new_trip(preferences: Preferences,
trip = Trip.from_linked_landmarks(linked_tour, cache_client)
logger.info(f'Generated a trip of {trip.total_time} minutes with {len(refined_tour)} landmarks in {round(t_generate_landmarks + t_first_stage + t_second_stage,3)} seconds.')
background_tasks = BackgroundTasks(fill_cache())
background_tasks.add(fill_cache())
return trip