Community Conundrum 25:Feature Visualization is now live! Read More

Scenario triggered from webapp

Level 1
Level 1
Scenario triggered from webapp

Hello,

I would like to trigger a DSS scenario from a button click in a DSS webapp.
I have tried the following code in the python backend part of the webapp:

from dataiku.scenario import Scenario
scenario = Scenario()
scenario.run_scenario("MY_SCENARIO_KEY")

I get the following error message in my backend.log:

API call '/dip/api/tintercom/scenarios/run-step/' failed
java.lang.IllegalArgumentException: The API ticket used is not associated with a scenario run

Is there any way to trigger a new scenario from a DSS webapp?

Thanks in advance for your help
Kind regards

 

2 Replies
Dataiker
Dataiker

Hi,

This API is intended to be used inside custom Python scenarios (https://doc.dataiku.com/dss/latest/scenarios/custom_scenarios.html).

To launch a scenario from a webapp, you need to use the public API: https://doc.dataiku.com/dss/5.0/publicapi/client-python/scenarios.html

from dataikuapi.dss.scenario import DSSScenario
client = dataiku.api_client()
dss_scenario = DSSScenario(client, PROJECT_KEY, SCENARIO_KEY)
dss_scenario.run()

Hope it helps,

Alex 

Level 1
Level 1
Author

Hi,

Yes, this works perfectly. Thanks a lot!!

Olivier