Announcing the winners & finalists of the Dataiku Frontrunner Awards 2021! Read their inspiring stories

using scenarioTriggerName in a scenario step condition

Romana
Level 3
using scenarioTriggerName in a scenario step condition

Hi, 

how can I reference the trigger name in a step condition of a scenario. 

In my situation I want to run step 1 only if the scenario has not been triggered manually, that means triggerName != 'Manual trigger'. But the variable 'triggerName' does not return any value.

Thank you,

Romana 

6 Replies
tim-wright
Neuron
Neuron

@Romana This is a good question and one that I thought would be relatively easy to find an answer for. 

https://doc.dataiku.com/dss/latest/scenarios/triggers.html#trigger-parameters Says that all triggers pass at least a name and type and some pass additional data (SQL or Python).

Looking here: https://doc.dataiku.com/dss/latest/scenarios/step_flow_control.html#if-condition-satisfied doesn't say anything about accessing the trigger name or type, just the params (if they are defined) as. Upon further inspection of the scenario variables I also did not find it.

 

One alternative way to do this is without too much difficulty is to make your very first step a Python Step that checks if the scenario was fired manually and then sets a scenario variable (accessible to subsequent scenario steps).

The Python Code:

 

from dataiku.scenario import Scenario

sc = Scenario()  # get the handle of the current running scenario
trigger_type = sc.get_trigger_type()  # get the type of trigger causing sc to run

# if triggered manually, set a scenario variable that can be used by other steps
if trigger_type == 'manual':
    sc.set_scenario_variables(scenario_trigger_type='manual')

# NOTE: the name of your variable in subsequent steps should match the name of the keyword argument in the set_scenario_variables() method call - Here I chose to Use 'scenario_trigger_type'.

 

To skip a downstream step if the event was triggered manually.

 

scenario_trigger_type.PNG

 

Let us know if this solution will do what you need it to. I'm fairly certain it does (if I understood the original question).

 

Thanks,

Tim

Romana
Level 3
Author

Hi @tim-wright ,

thank you very much for your answer. The solution does exactly what I want, but frankly I wanted to avoid python code. The official documentation claims there is a built in variable (which would make sense). I even found a variable "scenarioTriggerParams"  that returns a JSON - unfortunately empty. 

Would be great to get an official answer directly from Datiaku admins since it contradicts the documentation. 

Romana 

tim-wright
Neuron
Neuron

@Romana I completely agree and was also confused by the discrepancy from what I saw and what is in the documentation. It would indeed be great to hear from Dataiku on this.

One thing I stumbled across that could help awareness. I created a Python step in a scenario that just prints the available variables -- which I then inspect in the log after running the scenario: 

from dataiku.scenario import Scenario

sc = Scenario()  # get the handle of the current running scenario

#### LOOK FOR THIS IN THE LOG AFTER THE STEP RUNS ####
print('<<<<<<<< SCENARIO VARIABLES >>>>>>>>>> : {}'.format(sc.get_all_variables()))

# All the '<<<<..' just makes spotting this in the Log a little easier 

 .get_all_variables() will (reportedly) return all of the variables, including global, project and scenario specific ones. I see the a bunch of scenario specific variables including: 

scenarioTriggerParams
scenarioTriggerRunId

 But, I see nothing related to Trigger Name or Trigger Type. I would screenshot what I see in my logs, but it also contains some API keys (stored in my project variables).

Just an FYI

0 Kudos
dima_naboka
Dataiker
Dataiker
Hello,
 
Thanks for raising this up. We will be passing this to Product to consider implementing better UX functionality around this logic.
 
For the time being, please follow Tim’s suggestion
0 Kudos
tim-wright
Neuron
Neuron

@dima_naboka in addition to the UX logic, I think the part that is potentially misleading is here: https://doc.dataiku.com/dss/latest/scenarios/triggers.html#trigger-parameters where it states "All triggers pass at least their name and type" - not sure if that can be clarified in the documentation until it is implemented. 

Thanks @dima_naboka

0 Kudos
Damo
Level 2
Level 2

Hello,

Do we have any update for the above discussed feature. we have the same use case and trying to check the manual / auto trigger scenarios. Appreciate your help.

Thank you - Damo

0 Kudos
Labels (1)
A banner prompting to get Dataiku DSS