Skip to content

Conversation

@0yukali0
Copy link

@0yukali0 0yukali0 commented Nov 5, 2025

Tracking issue

flyteorg/flyte#6717

Why are the changes needed?

pyflyte command supports strong typing in pipeline and allow users to set the parameters by --var.
Supported None type make users set the None type or other values in their willing.

What changes were proposed in this pull request?

pyflyte run command parse None string to None type if type of parameter is Optional type.
pyflyte run --remote command parse None string to None type whether type of parameter is Optional type.

How was this patch tested?

# pyflyte run main.py hello --name None
# pyflyte run --remote main.py hello --name None

import flytekit as fl
from typing import Optional

@fl.task()
def hello(name: Optional[int] = None):
    print(name)

Setup process

  1. flytectl demo start
  2. uv venv -p 3.12
  3. uv pip install flytekit
  4. pyflyte run main.py hello --name None
  5. pyflyte run --remote main.py hello --name None

Screenshots

  1. Local mode
image
  1. Remote mode
image
  1. UI
image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

  • This pull request introduces support for the None type in parameter handling within the pyflyte command, allowing users to specify None as a valid input for optional parameters.
  • The changes ensure consistent behavior across both local and remote execution scenarios.
  • This update is crucial for users who need to pass None values explicitly in their workflows.
  • Overall summary: introduces support for None type in parameter handling, affecting local and remote execution.

Signed-off-by: yuteng <[email protected]>
@flyte-bot
Copy link
Contributor

Bito Automatic Review Skipped - Draft PR

Bito didn't auto-review because this pull request is in draft status.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change draft PR review settings here, or contact your Bito workspace admin at [email protected].

) from e


def is_optional(_type):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use is_optional_type from typing_inspect.

from typing_inspect import is_optional_type

if not self._is_remote:
return value

if is_optional(self._python_type) and value == "None":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if is_optional(self._python_type) and value == "None":
if is_optional(self._python_type) and value.lower() == "none":

Comment on lines 697 to 702
inputs_type = entity.python_interface.inputs
for input_name, v in entity.python_interface.inputs_with_defaults.items():
processed_click_value = kwargs.get(input_name)
input_type = inputs_type[input_name]
if is_optional(input_type) and processed_click_value == "None":
processed_click_value = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
inputs_type = entity.python_interface.inputs
for input_name, v in entity.python_interface.inputs_with_defaults.items():
processed_click_value = kwargs.get(input_name)
input_type = inputs_type[input_name]
if is_optional(input_type) and processed_click_value == "None":
processed_click_value = None
for input_name, v in entity.python_interface.inputs_with_defaults.items():
processed_click_value = kwargs.get(input_name)
input_type = .python_interface.inputs[input_name]
if is_optional(input_type) and processed_click_value == "None":
processed_click_value = None

Signed-off-by: yuteng <[email protected]>
@0yukali0 0yukali0 marked this pull request as ready for review November 6, 2025 00:13
@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.47%. Comparing base (3aebd23) to head (1452391).

Files with missing lines Patch % Lines
flytekit/interaction/click_types.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3348      +/-   ##
==========================================
- Coverage   47.70%   46.47%   -1.23%     
==========================================
  Files         216      216              
  Lines       22692    22626      -66     
  Branches     2972     2972              
==========================================
- Hits        10825    10516     -309     
- Misses      11289    11588     +299     
+ Partials      578      522      -56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants