Skip to content
Merged
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
20 changes: 17 additions & 3 deletions flows/xkcd-explainer/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def prompt(img_url):
@project_trigger(event="explain")
class XKCDExplainer(ProjectFlow):

xkcd_url = Parameter("xkcd_url", help="Image url of an XKCD comic")
xkcd_url = Parameter("xkcd_url", help="Image url of an XKCD comic", default="null")

@card(type="blank")
@step
Expand All @@ -76,10 +76,24 @@ def start(self):
self.img_url = self.xkcd_url
print(f"Using an image passed in as a parameter, {self.img_url}")
else:
self.img_url = self.prj.get_data("xkcd")
try:
self.img_url = self.prj.get_data("xkcd")
except Exception:
ref = self.prj._write_asset.peek_data_asset("xkcd")
from metaflow import get_namespace, namespace, Task
ns = get_namespace()
try:
namespace(None)
task = Task(ref["created_by"]["entity_id"])
self.img_url = task[ref["data_properties"]["annotations"]["artifact"]].data
finally:
namespace(ns)
print(f"Using an image from the latest data asset, {self.img_url}")

print(self.prj.asset.consume_model_asset("explainer-vlm"))
try:
print(self.prj.asset.consume_model_asset("explainer-vlm"))
except Exception:
print(f"No 'explainer-vlm' model on read branch '{self.prj.read_branch}' yet.")
self.next(self.prompt_vlm)

# ⬇️ add gpu=1 to @resources if you have GPU compute pools configured
Expand Down
2 changes: 1 addition & 1 deletion obproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ project = 'ob_project_starter'
title = 'XKCD Explainer'

[dev-assets]
branch = 'dev'
branch = 'main'
Loading