Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

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

4 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.

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
RinkaDink
Level 1

Good Morning,

 

I want the same as Onevirtual. The custom Trigger should trigger (fire) monday to friday every 3 hours between 8 am and 5 pm.

 

I dient clearly understand the Response and appreciate If you can post Code and what to set in run every or Grace delay

Thanks

 

0 Kudos
pkansal
Level 3

Hi,

 

I have configured my trigger just like above. I put the run every seconds at 60. But my trigger will not trigger at all.

0 Kudos