<#1214 fix File, Dir, DataFrame cli parsing with c...
# flyte-github
a
#1214 fix File, Dir, DataFrame cli parsing with collections Pull request opened by cosmicBboy This pull request significantly enhances the Flyte CLI's support for structured data types (such as
File
,
Dir
, and
DataFrame
) when passing parameters via JSON, especially for dataclasses and collections. It introduces robust recursive conversion of string paths within lists, dictionaries, and nested dataclasses into their appropriate Flyte types, ensuring a more seamless and type-safe CLI experience. Comprehensive tests are also added to validate these behaviors. Core Improvements to Parameter Handling • Refactored the
JsonParamType
in
src/flyte/cli/_params.py
to recursively convert string paths in lists, dicts, and dataclasses to proper
File
,
Dir
, and
DataFrame
objects, both for top-level and nested structures. This includes handling optional types and unions, and supports both path strings and structured dict formats. • Added logic to handle remote DataFrame paths in local mode, automatically inferring the format (CSV or Parquet) and creating a
DataFrame
object accordingly. Testing Enhancements • Introduced a comprehensive suite of tests in
tests/cli/test_run.py
to verify: • Conversion of lists and dicts of file/dataframe paths to Flyte objects. • Proper handling of dataclasses (including nested and optional fields) with
File
,
Dir
, and
DataFrame
fields. • Acceptance of both string and structured dict formats for these types. • Support for local and remote paths, and for both CSV and Parquet DataFrames. These changes make the CLI parameter parsing much more robust and user-friendly, especially for complex input types in Flyte workflows. flyteorg/flyte-sdk