The Dataiku Frontrunner Awards have just launched to recognize your achievements! Submit Your Entry

Scenario run Last Business date of the month

Solved!
Pauline
Level 1
Scenario run Last Business date of the month

Dear community,

I have just started using Dataiku and creating a couple of data models. 

I have used the automation scenario with simple by default settings offered by Dataiku. But now I would like to automate the run for one of my data models to run on a monthly basis for the Last Business date of the month.

 

Anyone on how I could achieve this?

 

Thank you! 

0 Kudos
1 Solution
VitaliyD
Dataiker
Dataiker

Hi Pauline,

Assuming you are using DSS version 9, you can use "Time-based" trigger and set "Repeat every" to 1 month and see if any condition will meet your requirements in the "Run on" dropdown. Please note: depending on the day selected, you may have some additional "Run on" dropdown option. Like in my example below, I chose the last Friday of the month, and that option appeared in the dropdown.

Screenshot 2021-04-09 at 09.07.36.png

Regarding your question to set up a trigger to run on the last business day of the month, there is no option available at the moment. However, you can utilise custom trigger and python code for such custom requirements. Please check an example I have created below:
Screenshot:

Screenshot 2021-04-09 at 11.02.52.png

Code:

 

import pandas as pd
from datetime import datetime
#get today's date in YYYY-MM-DD format
todaystr = datetime.today().strftime("%Y-%m-%d")
s = pd.date_range(todaystr, periods=1, freq='BM')
df = pd.DataFrame(s, columns=['Date'])
#get last working day of the current month from created dataframe above
lastBDCMstr = df.iloc[0]['Date'].strftime("%Y-%m-%d")
if lastBDCMstr == todaystr:
    from dataiku.scenario import Trigger
    t = Trigger()
    t.fire()

 


Above I utilised pandas, but for sure, there are many other ways to do it.

I hope this helps.

Best,
Vitaliy

View solution in original post

2 Replies
VitaliyD
Dataiker
Dataiker

Hi Pauline,

Assuming you are using DSS version 9, you can use "Time-based" trigger and set "Repeat every" to 1 month and see if any condition will meet your requirements in the "Run on" dropdown. Please note: depending on the day selected, you may have some additional "Run on" dropdown option. Like in my example below, I chose the last Friday of the month, and that option appeared in the dropdown.

Screenshot 2021-04-09 at 09.07.36.png

Regarding your question to set up a trigger to run on the last business day of the month, there is no option available at the moment. However, you can utilise custom trigger and python code for such custom requirements. Please check an example I have created below:
Screenshot:

Screenshot 2021-04-09 at 11.02.52.png

Code:

 

import pandas as pd
from datetime import datetime
#get today's date in YYYY-MM-DD format
todaystr = datetime.today().strftime("%Y-%m-%d")
s = pd.date_range(todaystr, periods=1, freq='BM')
df = pd.DataFrame(s, columns=['Date'])
#get last working day of the current month from created dataframe above
lastBDCMstr = df.iloc[0]['Date'].strftime("%Y-%m-%d")
if lastBDCMstr == todaystr:
    from dataiku.scenario import Trigger
    t = Trigger()
    t.fire()

 


Above I utilised pandas, but for sure, there are many other ways to do it.

I hope this helps.

Best,
Vitaliy

View solution in original post

Pauline
Level 1
Author

Hi Vitaliy,

 

The option in Dataiku version 9 looks pretty cool, unfortunately I have the 8th version.

 

But the custom trigger with the python code is super! I didn't realize this functionality. Thank you very much!

 

Best,

Pauline

0 Kudos
Labels (1)
A banner prompting to get Dataiku DSS