Trigger a scenario when project variables change?

info-rchitect
info-rchitect Registered Posts: 174 ✭✭✭✭✭✭

Hi,

I have a JSON hash stored as a project variable. Is there a way to trigger a scenario based on whether this variable changes?

thx


Operating system used: Windows 10

Tagged:

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,212 Dataiker
    edited July 17 Answer ✓

    Hi,

    There is no built-in trigger currently. You can use a custom python trigger every 30 minutes let's say.

    It would check the variable value and store another variable e.g last_value_read_by_scenario_trigger.

    Then after each run, you would update the variable "var_last_read" and if this is different then the variable you would trigger the scenario.

    Let me know if that works for you.

    from dataiku.scenario import Trigger
    t = Trigger()
    import dataiku
    
    project_handle = dataiku.api_client().get_project(dataiku.default_project_key())
    vars = project_handle.get_variables()
    
    if vars['standard']['varname'] != vars['standard']['var_last_read']:
        vars['standard']['var_last_read'] = vars['standard']['varname']
        project_handle.set_variables(vars)
        t.fire()

    Kind Regards,

Answers

Setup Info
    Tags
      Help me…