Hello, I have a workflow with a date: str paramete...
# ask-the-community
f
Hello, I have a workflow with a date: str parameter. When I create a launch plan from it, can I set the launch plan’s date inputs to be a dynamic value, e.g. to the current date in ‘2023-07-20’ format?
Copy code
launch_plan.LaunchPlan.get_or_create(
    workflow=wf, name="your_lp_name_1", default_inputs={"date": datetime.now().strftime("%Y-%m-%d")}, 
)
n
as far as I know the only way to pass in a dynamic value is through the
CronSchedule(…, kickoff_time_input_arg)
. The code you have there will have a hard-coded default input.
I guess you could refactor the workflow to dynamically create the date (this will cost a task, tho)
Copy code
@task
def create_now(date: Optional[str]) -> str:
    if date is None:
        return datetime.now().strftime(...)
    return date

@workflow
def wf(date: Optional[str] = None):
    now = create_now(date=date)
    ...
f
@Niels Bantilan, I tried below and it works.
Copy code
@workflow
def wf(
    dt: str = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
)
n
Really? Have you tried running on a flyte cluster? From what I understand the default value will be hard-coded at compile-time
f
Yes, it works.
n
I guess we can try again tomorrow :) if it’s “2023-07-21” then it works
f
@Niels Bantilan, Yes you are correct. The workflow got a fixed dt input value that is determined when the workflow is registered.
I will need to implement your strategy. Thanks