<#1096 fix pydantic/dataclasses default values at ...
# flyte-github
a
#1096 fix pydantic/dataclasses default values at serialization time Pull request opened by cosmicBboy This pull request introduces improved handling of default values for Pydantic and dataclass models in the Flyte CLI, especially for tasks with input defaults. It ensures that partial JSON provided via
--inputs
is shallow-merged with the task's default values before validation, preventing regressions with remote default handling and improving user experience. Additionally, the changes enhance JSON schema processing and type conversion, and add comprehensive tests and examples. Improvements to CLI default handling and input merging: • The
JsonParamType
class in
src/flyte/cli/_params.py
now accepts a
default_value
, and merges partial JSON input with the default before validation, supporting shallow merges for Pydantic/dataclass models. • The
literal_type_to_click_type
and related CLI parameter construction functions now propagate default values for improved option handling. Enhancements to JSON schema and type engine: • The JSON schema generation in
_json_schema.py
ensures that the
required
field is set appropriately based on property defaults, improving schema fidelity for dataclass and Pydantic models. • The dataclass type engine now tags struct types with their transformer and enforces correct type ownership when reversing types, preventing mismatches. • The dataclass schema-to-class conversion now properly handles field defaults, including mutable defaults, and uses a helper to append fields with correct default handling. Testing and examples: • Added new example and test files (
examples/cli/default_values_help.py
,
deploy_task_test.py
, and updated
tests/cli/test_run_remote_defaults.py
) demonstrating and verifying correct behavior for deployed tasks with input defaults and partial JSON input. These changes collectively address previous issues with default handling in the CLI, improve schema and type safety, and add robust regression tests to prevent future issues. flyteorg/flyte-sdk