most-telephone-75272
02/01/2024, 8:31 AMstart on the UI.
@card(type="html")
@catch(var="error")
@step
def start(self):
self.html = """<h1>hello world</h1>"""
raise Exception("boom!")
self.next(self.end)
def end(self):
if self.error:
raise self.error
However the problem is I can't retry that step on argo because as start has the catch it didn't fail. The step that fails is end
I would like to do something like this
@card(type="html")
@step
def start(self):
self.html = """<h1>hello world</h1>"""
raise Exception("boom!")
Or like this where start step fails but already produced cards are accesible through metaflow UI.
@card
@step
def start(self):
current.card.append(HTMLCard(html=html))
raise Exception("boom!")brave-lion-15961
02/01/2024, 9:54 AMbrave-lion-15961
02/01/2024, 9:59 AMmost-telephone-75272
02/01/2024, 9:59 AMmost-telephone-75272
02/01/2024, 9:59 AMmost-telephone-75272
02/01/2024, 1:00 PMfrom metaflow.cards import Markdown
from metaflow import (
FlowSpec,
card,
current,
project,
step,
)
@project(name="dnn")
class TestFlow(FlowSpec):
@card
@step
def start(self):
current.card.append(Markdown("Hello World"))
import time
time.sleep(2)
1/0
self.next(self.end)
@step
def end(self):
print("Done")
if __name__ == "__main__":
TestFlow()most-telephone-75272
02/01/2024, 1:00 PMhallowed-glass-14538
02/01/2024, 5:04 PMcurrent.card.refresh() to ensure the card is created. Cards are by default created when tasks end but to ensure that they are present during task execution, you can just drop a current.card.refresh() during task execution.
you need to change your flow to
from metaflow.cards import Markdown
from metaflow import (
FlowSpec,
card,
current,
project,
step,
)
@project(name="dnn")
class TestFlow(FlowSpec):
@card
@step
def start(self):
current.card.append(Markdown("Hello World"))
import time
current.card.refresh()
time.sleep(2)
1/0
self.next(self.end)
@step
def end(self):
print("Done")
if __name__ == "__main__":
TestFlow()most-telephone-75272
02/01/2024, 6:37 PMmost-telephone-75272
02/01/2024, 6:37 PMmost-telephone-75272
02/01/2024, 6:37 PMhallowed-glass-14538
02/01/2024, 8:32 PMfrom metaflow import FlowSpec, card, step, current
from datetime import datetime
class HTMLCardFlow(FlowSpec):
@card(type='html')
@step
def start(self):
HTML = """
<html>
<body style="background: #FF5733; font-family: sans-serif; margin: 150px">
<h1 style="color: white">Time is {time}</h1>
</body>
</html>
"""
t = datetime.now().isoformat()
current.card.refresh({'html': HTML.format(time=t)})
self.next(self.end)
@step
def end(self):
pass
if __name__ == '__main__':
HTMLCardFlow()