flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

support passing optional date through CLI

Open blaketastic2 opened this issue 7 months ago • 5 comments

Why are the changes needed?

Currently, if we have a workflow with an optional date parameter, we cannot call this from the CLI.

Workflow definition:

@workflow
def ingest_data(
    start_date: Optional[date] = None,
) -> None:
    pass

Executing the workflow:

pyflyte run --copy all -p flyte-snacks -d development --remote workflow.py ingest_data --start_date 2025-06-10

Produces this error:

Invalid value for '--start_date': Failed to convert param: <Option start_date>, value: 2025-06-10 00:00:00 to type: typing.Optional[datetime.date]. Reason
Cannot convert from 2025-06-10 00:00:00 to typing.Optional[datetime.date]

What changes were proposed in this pull request?

We are now making sure to use the non-None variant when trying to do the conversion.

Summary by Bito

This pull request enhances the CLI's handling of optional date parameters by improving type conversion, specifically addressing datetime to optional date type conversions to prevent type mismatch errors. These enhancements aim to improve user experience in workflows requiring date parameters.

blaketastic2 avatar Jun 11 '25 21:06 blaketastic2