https://flyte.org logo
#ask-the-community
Title
# ask-the-community
a

Adedeji Ayinde

03/03/2023, 10:54 PM
Hello, is there a way to get the execution date of a task or workflow scheduled to run at intervals. The idea is to dynamically pass in the execution date as parameter in the task/workflow. Also, if there is need to rerun a task from past runs, the specific execution date for that run will be passed and not the current date.
f

Fabio Grätz

03/04/2023, 10:40 AM
Does this maybe help you?
Copy code
@workflow
def date_formatter_wf(kickoff_time: datetime):
    formatted_kickoff_time = format_date(run_date=kickoff_time)
    print(formatted_kickoff_time)
Copy code
cron_lp = LaunchPlan.get_or_create(
    name="my_cron_scheduled_lp",
    workflow=date_formatter_wf,
    schedule=CronSchedule(
        # Note that the ``kickoff_time_input_arg`` matches the workflow input we defined above: kickoff_time
        # But in case you are using the AWS scheme of schedules and not using the native scheduler then switch over the schedule parameter with cron_expression
        schedule="*/1 * * * *",  # Following schedule runs every min
        kickoff_time_input_arg="kickoff_time",
    ),
)
k

Ketan (kumare3)

03/04/2023, 11:20 PM
a

Adedeji Ayinde

03/05/2023, 4:10 AM
Thanks @Fabio Grätz @Ketan (kumare3)
73 Views