How to fetch "thrown" error message from get_details()?
I want to capture the thrown error message from json by get_details(). There are currently multiple steps in build dataset and one of the steps gets failed and I need to fetch the error message of the failed step which is present inside "thrown". So, could you please help me identify the hierarchy through which I can fetch the "thrown" error message from get_details()? Thanks in advance.
Answers
-
Sarina Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 317 Dataiker
Hi @rs0105
,
Here's an example of pulling the "thrown" scenario result field for any steps within a scenario that failed.import dataiku from dataiku import pandasutils as pdu import pandas as pd client = dataiku.api_client() project = client.get_project('YOUR_PROJECT') scenario = project.get_scenario('YOUR_SCENARIO') # gets the most recent scenario run last_run = scenario.get_last_finished_run() # for each step within the scenario, get the step "status". for step in last_run.get_details()['stepRuns']: # If the step failed, get the step name and "throw" field: if step['result']['outcome'] == 'FAILED': # log "Thrown" message print('Step name: ' , step['step']['name']) print('Error: ', step['result']['thrown'])
In the above, the "step" object will contain the details for each step. You can print it to take a look at the full details. Within the "result" key, you'll get information on the step success or failure in addition to the "thrown" field that will contain the error details for that specific step. Within the "step" key, you'll find information about the actual step (name, id).
Here's a brief example where I have a scenario that failed in the second step:When I run the above code on this scenario, I get the name of the step and the thrown error message back, just for the failed step:
If this doesn't address your use case, could you provide a little more detail and attach some screenshots illustrating your use case for us to take a look?
Thank you,
Sarina