🚀 New! Kestra raises $3 million to grow Learn more

Home / Solutions / Blueprints

Run specific tasks only on business days for a specific country

Plugins Used in this Blueprints

About this blueprint

Run specific tasks only on business days for a specific country

This flow will run one or more tasks only on business days for a specific country. The Python script in this flow checks if the date is a business day for the specified country. If it is, the flow continues to the next task. If it is not, the task fails, blocking the execution of subsequent tasks.

The Pebble expression "{{trigger.date ?? inputs.date}}" will make sure that the flow will use either the schedule date from the trigger or the date provided on the date input at runtime. You can use the inputs to test the logic.

Make sure adjust the Python script to match your desired country.

To add the Python script, go to the VS Code Editor in the Kestra UI and add the script schedule.py:

import sys
from datetime import datetime
from workalendar.europe import France  # Import calendars for specific countries
from workalendar.usa import UnitedStates  # Example for another country

def is_business_day(date_str, country_calendar):
    # Remove 'Z' from kestra's timezone-specific timestamp and parse the date string
    date = datetime.fromisoformat(date_str.replace("Z", ""))

    # Check if the date is a business day
    return country_calendar.is_working_day(date)

def main():
    if len(sys.argv) != 3:
        print("Usage: script.py <date> <country_code>")

    date_str, country_code = sys.argv[1], sys.argv[2]

    # Dictionary mapping country codes to calendar objects
    calendars = {
        "FR": France(),
        "US": UnitedStates(),

    country_calendar = calendars.get(country_code.upper())
    if not country_calendar:
        print(f"Calendar for '{country_code}' not supported or not found.")

        if not is_business_day(date_str, country_calendar):
            print(f"{date_str} is not a business day in {country_code}.")
            print(f"{date_str} is a business day in {country_code}.")
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":

This way, you can store and manage your custom scripts using Namespace Files rather than pasting them inline in YAML.

New to Kestra?

Use blueprints to kickstart your first workflows.