We're excited to announce that we're launching the second installment of Dataiku Product Days Register Now

Custom python trigger time-conditioned won't launch Scenario

Solved!
onevirtual
Level 1
Custom python trigger time-conditioned won't launch Scenario

So I went to the dataiku academy and built my custom trigger with the template provided in order to run my scenario on week-days at business hours. Which resulted eventually in this code :

 

from dataiku.scenario import Trigger
from datetime import date
from datetime import datetime

t = Trigger()
aujourdhui = date.today()
heure = datetime.today()
heure_actuelle = heure.hour

if aujourdhui.weekday() >= 0 and aujourdhui.weekday() < 5:
    if heure_actuelle > 8 and heure_actuelle < 21:
        t.fire()

 

Problem is, this code won't trigger the scenario. According to the template I built this code on, there are no reasons why this trigger won't launch the scenario. For info, the scenario is within the project I 'use'/write the custom trigger. I left the 3600 seconds (run every seconds parameter) to default.

I tried to use a time based trigger which effectively launched at a certain time of the hour, but I thought it would work the same way according to the conditions in the code above.

Please, can you provide an explanation why this code won't launch my scenario every hour and see if the conditions are met ?

PS : Obvsiouly I tried it within the time span the conditions are based on.

 

 

1 Solution
AurelienD
Dataiker
Dataiker

Hello,

Did you ticked the little checkbox "Auto-triggers"?Screen Shot 2021-03-02 at 3.51.32 PM.png

To debug your custom trigger, you can reduce the "Run Every", put some print and check in the log if you see your message.

View solution in original post

2 Replies
AurelienD
Dataiker
Dataiker

Hello,

Did you ticked the little checkbox "Auto-triggers"?Screen Shot 2021-03-02 at 3.51.32 PM.png

To debug your custom trigger, you can reduce the "Run Every", put some print and check in the log if you see your message.

View solution in original post

onevirtual
Level 1
Author

Hello, thank you for the fast reply. The problem was due to my understanfing of the run every (3600 s) function, which I thought would work like that (immediatly run while active on is ticked and run every default seconds after). Instead, I understand now that the function is coded to have a starttime run with the latency of variable equals to parameter variable from actual time.

I will mark the issue as resolved thank you (:

0 Kudos
A banner prompting to get Dataiku DSS