Using variables to ensure a scenario only runs once a day

ben_p
ben_p Neuron 2020, Registered, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant Posts: 143 ✭✭✭✭✭✭✭

Hi fellow DSS users,

I have a scenario that currently triggers once a day - once when certain criteria are met, and again when they are no longer met. The first it great, working as I want it too, the second is unwanted and I would like to add some login so this second run doe snot happen.

I have tried to do this by creating a new Global variable:

"segment_trigger": "True"

And then adding this to be SQL trigger like so:

WHEN '${segment_trigger}' = "True"
AND ...

Then the final step in my scenario sets this value to "False":

ben_p_0-1583756684405.png

My thinking is that my variable will be set to "True" every morning (I refresh my variables in another scenario), then after the scenario runs the first time the value will be "False", so the trigger will not fire the second time.

However, my scenario is STILL running twice a day. What am i missing? Is DSS resetting the value of segment_trigger to "True" every time I run a scenario?

Best,
Ben

Best Answer

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    Answer ✓

    Hi,

    if the step where you set the variable to false is a "set global variables" one, then your flip-floping of segment_trigger has no reason not to work. You should check

    • the logs of the scenario step that sets the variables for error
    • the global variables' state after a run to make sure its value is "False"
    • that there are no project variables that would shadow the global variables
    • that when changing the global variable manually the SQL trigger stops triggering for the day, even when the other criteria are met (the '...' = "True" is strange, since double-quotes are used for identifiers in many DBs)

    A possible dirtier solution could be to set the scenario to inactive at the end of its run (using the python wrapper on the DSS public API) and set it to active again in your daily scenario.

    Regards,

    Frederic

Answers

  • ben_p
    ben_p Neuron 2020, Registered, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant Posts: 143 ✭✭✭✭✭✭✭

    Hi Frederic,

    When you say:


    (the '...' = "True" is strange, since double-quotes are used for identifiers in many DBs)

    Are you suggesting that I should change this too WHEN "${segment_trigger}" = "True"

    Ben

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker

    actually, I would expect '${segment_trigger}' = 'True' .

    But that depends on the actual DB

  • ben_p
    ben_p Neuron 2020, Registered, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant Posts: 143 ✭✭✭✭✭✭✭

    The DB is BigQuery, I expect " to work, but I have changed to ' to see if there is any impact!

Setup Info
    Tags
      Help me…