How go get error details when scenario run_and_wait function fails

Options
arielma2304
arielma2304 Registered Posts: 47 ✭✭✭✭
edited 3:53PM in General Discussion

Hi

I'm using this code

client = dataikuapi.DSSClient(params['host'], params['api'])
client._session.verify = False
project = client.get_project(params['project'])
scenario_id = scenario["id"]
scenario_result = project.get_scenario(scenario_id).run_and_wait()

and I see in the Junit results, the function has its own error handling:

outcome = self.scenario_run.run.get('result', None).get('outcome', 'UNKNOWN')
if outcome == 'SUCCESS' or no_fail:
   return self.scenario_run
else:
   raise DataikuException("Scenario run returned status %s" % outcome)
   dataikuapi.utils.DataikuException: Scenario run returned status FAILED

how can I get more details about the error if I can't control it? For example, can I use here first_error_details?

get-the-first-error-that-happened-in-a-scenario-run

Best Answer

  • AlexandreV
    AlexandreV Dataiker Posts: 28 Dataiker
    Answer ✓
    Options

    Hi,
    another possibility is to use

    scenario_result = project.get_scenario(scenario_id).run_and_wait(no_fail=True)

    and then get the result in

    scenario_result.run["result"]

    Hope it helps, otherwise can you tell me a bit more about what error details you need, or what control you need overrun_and_wait()?

    Best,

    Alex


Answers

  • AlexandreV
    AlexandreV Dataiker Posts: 28 Dataiker
    Options

    Hi,

    You can indeed use first_error_details as described in Get the first error that happened in a scenario run .
    Another way to get more info would be to go to the Jobs tab in DSS, in your project.

    Alex

  • arielma2304
    arielma2304 Registered Posts: 47 ✭✭✭✭
    Options

    But how I can use it in Pytest if I can't control on what happens in run_and_wait() function? where exactly I can use it?

  • arielma2304
    arielma2304 Registered Posts: 47 ✭✭✭✭
    Options

    Actually it does help

    however, when I ran this line:

    assert scenario_result.get_details()["scenarioRun"]["result"]["outcome"] == "SUCCESS", "test " + scenario["name"] + " failed" + "Error was: %s" % (scenario_result.get_details().first_error_details)

    I thought I will get more details, but all I got was:

    AssertionError: test TEST_always_fails failedError was: None

    I guess this is the correct behavior per DSS documentation:

    "Try to get the details of the first error if this run failed. This will not always be able to find the error details (it returns None in that case)"

    The question is in which cases it return not None?

Setup Info
    Tags
      Help me…