trigger based on python script
pkansal
Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 23 ✭✭✭✭
I am trying to trigger a scenario based on python script but it is not working. It doesn't trigger at all.
Can someone tell me what I am doing wrong?
The script is :
from dataiku.scenario import Trigger
from datetime import date
import pytz
tz = pytz.timezone('Europe/Amsterdam')
t = Trigger()
now = datetime.datetime.now(tz = tz)
dayofweek =now.isoweekday()
hour = now.hour
if dayofweek in [1,2,3,4,5] and (hour >= 7 and hour <=23):
t.fire()
Tagged:
Best Answer
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,215 Dataiker
Hi @pkansal
,I think your import datetime is not working
Can you try :
from dataiku.scenario import Trigger from datetime import datetime import pytz tz = pytz.timezone('Europe/Amsterdam') t = Trigger() now = datetime.now(tz = tz) dayofweek =now.isoweekday() hour = now.hour if dayofweek in [1,2,3,4,5] and (hour >= 7 and hour <=23): t.fire()
Answers
-
Thanks! It works now.