careful-dress-39510
12/20/2021, 9:54 PM@catch
decorator to expose the actual exception that was thrown in the code?
Wondering if I can share this as a more specific error message when potentially logging to an external service like Slack rather than just saying the step failed.dry-beach-38304
12/20/2021, 10:07 PMcareful-dress-39510
12/20/2021, 10:07 PMcareful-dress-39510
12/20/2021, 10:08 PMvictorious-lawyer-58417
12/20/2021, 10:09 PM@catch(var='compute_failed')
) - you can access the compute_failed
artifact e.g. in a notebookcareful-dress-39510
12/20/2021, 10:12 PMvictorious-lawyer-58417
12/20/2021, 10:13 PMfrom metaflow import FlowSpec, catch, step
class CatchFlow(FlowSpec):
@step
def start(self):
self.params = range(3)
self.next(self.compute, foreach='params')
@catch(var='compute_failed')
@step
def compute(self):
self.div = self.input
self.x = 5 / self.div
self.next(self.join)
@step
def join(self, inputs):
for input in inputs:
if input.compute_failed:
print('compute failed for parameter: %d' % input.div)
self.next(self.end)
@step
def end(self):
pass
if __name__ == '__main__':
CatchFlow()
careful-dress-39510
12/20/2021, 10:14 PMcareful-dress-39510
12/20/2021, 10:14 PMvictorious-lawyer-58417
12/20/2021, 10:16 PMprint(input.compute_failed)
in the above examplecareful-dress-39510
12/20/2021, 10:16 PMcareful-dress-39510
12/20/2021, 10:24 PMvictorious-lawyer-58417
12/20/2021, 10:27 PMint
, float
, bool
, str
are supported as native types, and then JSON for more complex types.
you can do e.g.
some_int = Parameter('some_int`, default=5)
this makes some_int
a Python integervictorious-lawyer-58417
12/20/2021, 10:28 PMstart
stepcareful-dress-39510
12/20/2021, 11:22 PM