Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/image-telephone/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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}")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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}")


Expand Down
Loading