Hi there, I was looking at the error handling <he...
# dev-metaflow
c
Hi there, I was looking at the error handling here. Is there any way with the
@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.
1
d
It stores it (or a wrapper to it) in the var specified in the decorator. Are you looking for something else?
c
That is what I was after, that is great, thanks
👍 1
might be useful to add an example of that in the docs, thats where I got lost
v
there's an example of it here https://docs.metaflow.org/metaflow/failures#exceptions-raised-by-your-code (see
@catch(var='compute_failed')
) - you can access the
compute_failed
artifact e.g. in a notebook
c
could I be seeing a cached older version of the docs? I can't see that referenced doing a ( ctrl + F ) on compute failed, I see it printed, and the input logged, not the error message
v
this is the example in docs:
Copy code
from 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()
c
I see that, but I dont see where the exception message is being extracted form the variable self.compute_failed
as @dry-beach-38304 pointed out, it can be done
v
ah, right. You can add e.g.
print(input.compute_failed)
in the above example
c
🙌
Another one while I have you, is there a way to provide python objects as parameters or is it only string and json ?
v
int
,
float
,
bool
,
str
are supported as native types, and then JSON for more complex types. you can do e.g.
Copy code
some_int = Parameter('some_int`, default=5)
this makes
some_int
a Python integer
other Python objects you can have to handle manually e.g. in the
start
step
c
awesome, cheers!
👍 1