Hello :wave: As part of our current migration, we ...
# ask-the-community
h
Hello 👋 As part of our current migration, we have set up a launch plan which is scheduled to run daily at 7. The workflow expects an
input_date
as one of the parameter. This launch plan was updated in the cluster yesterday (2023-07-12). While we were expecting todays execution to pick the input date as 2023-07-13 we noticed that it picked 2023-07-12 instead (This is our first scheduled run). Is our assumption right that its because of this
default_inputs={"date": datetime.today().strftime("%Y-%m-%d")}
that it is set only once while the launch plan is updated or created and hence picking that date?
Copy code
LaunchPlan.get_or_create(
        name=f"launch_plan_{ecosystem}",
        workflow=test_workflow,
        schedule=CronSchedule(schedule="0 7 * * *"),
        default_inputs={"date": datetime.today().strftime("%Y-%m-%d")},
        fixed_inputs={"ecosystem": ecosystem},
    )
Is there a better way to handle input dates ? All our pipelines expects an input date as parameter; for some it’s the same date as execution date and for some it’s one day behind the execution date.
t
Hey @Hema Jayachandran, I think your assumption is correct: the default_inputs containing the date will be evaluated when the LaunchPlan is created during package/registration and will contain this same date each time it is run. To pass your pipeline today's date, I'd just start the workflow with a task (or an @dynamic if appropriate) that computes any input params needed for the pipeline, including fetching the current date if your pipeline can't do this internally.
h
Thank you @Thomas Blom for getting back on this. We will try the approach you suggested gratitude thank you
d
Thanks @Thomas Blom, your help is much appreciated 🙂
s
@Hema Jayachandran, you can use the
kickoff_time_input_arg
to send the current date. https://docs.flyte.org/projects/cookbook/en/latest/getting_started/run_schedule.html#passing-in-the-scheduled-kick-off-time
h
Thank you @Samhita Alla, we saw this one but majority of our pipelines needs input date as
Copy code
current_date - 1
Is it possible to achieve it through this
kickoff_time_input_arg
?
s
Can you do the computation within the task? That should work.
h
Yes, we are working on it 🙂
I am passing the date as
Optional[str]
so that when it’s
None
, it picks the current date else we manually override it with a date if needed. It works fine when I launch the workflow from the console but it doesn’t work when launching the workflow with
exec_spec.yaml
in this case
Copy code
inputs:
    input_date: null
It throws
Copy code
Message:
    time data '' does not match format '%Y-%m-%d'
It looks like the
null
is not picked as None.
s
You mean when launching the workflow with flytectl?
h
Yes
Copy code
flytectl create execution -p ${MODULE_NAME} -d ${DOMAIN} --execFile exec_spec.yaml
s
If it's
Optional[str]
, why does the error include the date time format?
h
Nice catch. It looks like it’s a bug in our internal config library. I will take a look if thats the causegratitude thank you