Submit your inspiring success story or innovative use case to the 2022 Dataiku Frontrunner Awards! ENTER YOUR SUBMISSION

trigger based on python script

Solved!
pkansal
Level 3
trigger based on python script

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()

0 Kudos
1 Solution
AlexT
Dataiker
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()

 

 

View solution in original post

2 Replies
AlexT
Dataiker
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()

 

 

pkansal
Level 3
Author

Thanks! It works now.

0 Kudos