Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I am using the Python REST API to create scenarios in Dataiku.
This has all been successful however I am now trying to include trigger information in the create_scenario call.
If I use 'Daily' as the frequency and provide it an hour and minute in the JSON it works fine.
However, I am unsure how to schedule other types of triggers. For example every 180 mins or to start on a specific day.
Please could you assist me with this by showing me how to configure the parameter for the create_scenario API call for different types of triggers.
Hi @ArvinUbhi ,
The Python API has a handful of functions that you can use to create time-based triggers more easily. Here are some examples:
# Create a scenario and get its settings scenario = project.create_scenario('SCENARIO_ID', type='step_based') settings = scenario.get_settings() # Trigger every 180 minutes settings.add_periodic_trigger(every_minutes=180) # Trigger every 4 hours starting today at 12:30 settings.add_hourly_trigger(starting_hour=12, minute_of_hour=30, repeat_every=4) # Trigger every day at 17:00 starting on 2022-08-07 settings.add_daily_trigger(hour=17, year=2022, month=8, day=7) # Trigger every Tuesday and Thursday at 3:20 settings.add_daily_trigger(hour=3, minute=20, days=('Tuesday', 'Thursday')) # Trigger every month on the 8th at 20:15 settings.add_monthly_trigger(day=8, hour=20, minute=15) # Set the scenario as active so that the triggers will run settings.active = True # Save your changes. Any changes that you make to `settings` won't be # saved without this settings.save()
See the reference documentation for a list of available functions and parameters.
If you want to create a trigger that isn't covered by the above functions, you can create the trigger via the GUI, and then view the definition for reference:
# Get the settings of an existing scenario scenario = project.get_scenario('SCENARIO_ID') settings = scenario.get_settings() # View the triggers from the scenario. # You can add these to the definition when using `create_scenario()` print(settings.raw_triggers)
Please let me know if you have any questions.