trigger based on python script

Options
pkansal
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
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,209 Dataiker
    Answer ✓
    Options

    Hi @pkansal
    ,

    I think your import datetime is not working

    Can you try :

    from dataiku.scenario import Triggerfrom datetime import datetimeimport pytztz = pytz.timezone('Europe/Amsterdam')t = Trigger()now = datetime.now(tz = tz)dayofweek =now.isoweekday()hour = now.hourif dayofweek in [1,2,3,4,5] and (hour >= 7 and hour <=23):t.fire()

Answers

Setup Info
    Tags
      Help me…