From 32628c9b9654a9397ee9114b4522b9dc265c8142 Mon Sep 17 00:00:00 2001 From: Susan Stillman Date: Thu, 19 Dec 2024 18:52:33 -0700 Subject: [PATCH] bugfix and add separate try/except for roda (after titiler metadata) --- cerulean_cloud/cloud_run_orchestrator/clients.py | 4 +--- cerulean_cloud/cloud_run_orchestrator/handler.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cerulean_cloud/cloud_run_orchestrator/clients.py b/cerulean_cloud/cloud_run_orchestrator/clients.py index 0d167a58..f37cd42a 100644 --- a/cerulean_cloud/cloud_run_orchestrator/clients.py +++ b/cerulean_cloud/cloud_run_orchestrator/clients.py @@ -199,9 +199,7 @@ async def send_inference_request_and_handle_response(self, http_client, img_arra await asyncio.sleep(retry_delay) # Wait before retrying # If all attempts fail, raise an exception - raise Exception( - f"All attempts failed after {max_retries} retries. Last known error: {res.content}" - ) + raise Exception(f"All inference attempts failed after {max_retries} retries.") async def get_tile_inference(self, http_client, tile_bounds, rescale=(0, 255)): """ diff --git a/cerulean_cloud/cloud_run_orchestrator/handler.py b/cerulean_cloud/cloud_run_orchestrator/handler.py index fc55b3fb..2e4fac3c 100644 --- a/cerulean_cloud/cloud_run_orchestrator/handler.py +++ b/cerulean_cloud/cloud_run_orchestrator/handler.py @@ -264,7 +264,6 @@ async def _orchestrate( try: scene_bounds = await titiler_client.get_bounds(payload.sceneid) scene_stats = await titiler_client.get_statistics(payload.sceneid, band="vv") - scene_info = await roda_sentinelhub_client.get_product_info(payload.sceneid) except Exception as e: logger.error( structured_log( @@ -276,6 +275,19 @@ async def _orchestrate( ) return OrchestratorResult(status=str(e)) + try: + scene_info = await roda_sentinelhub_client.get_product_info(payload.sceneid) + except Exception as e: + logger.error( + structured_log( + "Roda Sentinel Hub error", + severity="ERROR", + scene_id=payload.sceneid, + exception=str(e), + ) + ) + return OrchestratorResult(status=str(e)) + try: async with DatabaseClient(db_engine) as db_client: async with db_client.session.begin():