Custom Trigger Monthly Open Days
Hello,
I'm trying to launch scenario with custom trigger the first open day of each month. Did someone could help me on that ?
Thanks
Best Answer
-
I finallly found the solution :
from dataiku.scenario import Trigger
import pandas as pd
from datetime import date , datetime
import pytz
t = Trigger()liste= pd.date_range('1/1/2023',periods=100, freq='BMS')
tz = pytz.timezone('Europe/Paris')
hour = datetime.now(tz = tz).hour
if date.today() in liste and hour>9 :
t.fire()
Answers
-
Ioannis Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 28 ✭✭✭✭✭
You can use this library. You can see some examples here as well.
import dataikuapiimport dataikufrom dataiku.scenario import Triggerimport datetime# 1st approachclient = dataiku.api_client()project = client.get_project("your_project")scenario = project.get_scenario("myscenario")trigger_fire = scenario.run()if today ==1:scenario_run = trigger_fire.wait_for_scenario_run()# 2nd approacht = Trigger()today = datetime.datetime.today().dayif today == 1:t.fire() -
Thanks for your help, but my problem is to run the scenario the first OPEN day of the month. So if the first is a sunday, the scenario should run the 2nd, monday.
-
Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker
Hi,
I suspect that by open day you actually mean business day?
If so you can take advantage of pandas date_range method. In your custom python trigger you could input.
from dataiku.scenario import Trigger import pandas as pd from datetime import date t = Trigger() if date.today() in pd.date_range('1/1/2023', '12/1/2023', freq='BMS') t.fire()