Community Conundrum 28: News Engagement is live! Read More

Continue custom python scenario script if error is encountered

Level 2
Continue custom python scenario script if error is encountered

Hi,

When building a scenario using the sequence of steps option, it's possible to select ignore failure for 'Run another scenario' step.  Is there a way to ignore failure in the custom python scenario script?  

In the below example, "scenario.run_scenario('Test_Tables_Databases')" will run a scenario that will fail because it is executing scenario.execute_sql() on a table that doesn't exist (for test purposes).  Once that scenario fails then the current scenario will stop.  Is there a way to run my custom python scenario script without stopping if a failure is encountered?

import dataiku
from dataikuapi.dss.scenario import DSSScenario
from dataiku.scenario import Scenario

client = dataiku.api_client()
scenario = Scenario()

# Run the scenario that checks each table for database locks
scenario.run_scenario('Test_Tables_Databases')

dss_scenario_test = DSSScenario(client, dataiku.default_project_key(), "Test_Tables_Databases")

# Check if 'test' scenario succeeded or failed
outcome = dss_scenario_test.get_last_runs()[0].get_info()['result']['outcome']

if outcome == 'SUCCESS':

scenario.run_scenario('Build_Final_Dataset')

#elif outcome == 'FAILED':

 

2 Replies
Dataiker
Dataiker

Hi,

You should be able to achieve such behavior using the Public API:

https://doc.dataiku.com/dss/latest/python-api/rest-api-client/scenarios.html#dataikuapi.dss.scenario...

Hope it helps,

Alex

Level 2
Author

Thanks, got it to work.

removed run_scenario() and added dss_scenario_test.run_and_wait(no_fail=True).

0 Kudos
A banner prompting to get Dataiku DSS