From e313dce83efb2efb7ffd2c26eb76866a3ff0a0a6 Mon Sep 17 00:00:00 2001 From: Ghraven Date: Wed, 12 Aug 2026 06:09:55 +0800 Subject: [PATCH] fix(examples): bound image telephone downloads --- examples/image-telephone/application.py | 8 +++++++- .../integrations/hamilton/image-telephone/application.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/image-telephone/application.py b/examples/image-telephone/application.py index fa5aaf773..35ab29847 100644 --- a/examples/image-telephone/application.py +++ b/examples/image-telephone/application.py @@ -42,6 +42,8 @@ from burr.core.action import action from burr.lifecycle import PostRunStepHook +IMAGE_DOWNLOAD_TIMEOUT_SECONDS = 30 + # import hamilton modules that define the DAGs for image captioning and image generation caption_images = dataflows.import_module("caption_images", "elijahbenizzy") generate_images = dataflows.import_module("generate_images", "elijahbenizzy") @@ -67,7 +69,11 @@ def post_run_step(self, *, state: "State", action: "Action", **future_kwargs): image_url = state["current_image_location"] image_name = "image_" + str(state["__SEQUENCE_ID"]) + ".png" with open(os.path.join(self.path, image_name), "wb") as f: - f.write(requests.get(image_url).content) + response = requests.get( + image_url, timeout=IMAGE_DOWNLOAD_TIMEOUT_SECONDS + ) + response.raise_for_status() + f.write(response.content) print(f"Saved image to {self.path}/{image_name}") diff --git a/examples/integrations/hamilton/image-telephone/application.py b/examples/integrations/hamilton/image-telephone/application.py index 4f7f5fa1d..44b44b5ab 100644 --- a/examples/integrations/hamilton/image-telephone/application.py +++ b/examples/integrations/hamilton/image-telephone/application.py @@ -33,6 +33,8 @@ from burr.integrations import hamilton from burr.lifecycle import PostRunStepHook +IMAGE_DOWNLOAD_TIMEOUT_SECONDS = 30 + caption_images = dataflows.import_module("caption_images", "elijahbenizzy") generate_images = dataflows.import_module("generate_images", "elijahbenizzy") @@ -53,7 +55,11 @@ def post_run_step(self, *, state: "State", action: "Action", **future_kwargs): image_url = state["current_image_location"] image_name = "image_" + str(state["__SEQUENCE_ID"]) + ".png" with open(os.path.join(self.path, image_name), "wb") as f: - f.write(requests.get(image_url).content) + response = requests.get( + image_url, timeout=IMAGE_DOWNLOAD_TIMEOUT_SECONDS + ) + response.raise_for_status() + f.write(response.content) print(f"Saved image to {self.path}/{image_name}")