Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flytekit/clis/sdk_in_container/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def _get_params(
for name, var in inputs.items():
if fixed and name in fixed:
continue
required = True
required = not is_optional(native_inputs[name])
default_val = None
if defaults and name in defaults:
if not defaults[name].required:
Expand Down
31 changes: 30 additions & 1 deletion tests/flytekit/unit/cli/pyflyte/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from flytekit.interaction.click_types import DirParamType, FileParamType
from flytekit.remote import FlyteRemote
from typing import Iterator, List
from typing import Iterator, List, Optional
from flytekit.types.iterator import JSON
from flytekit import workflow, LaunchPlan

Expand Down Expand Up @@ -1022,3 +1022,32 @@ def example_workflow(x: int) -> int:
assert call_args[2] == "some_module.example_workflow"
assert call_args[3] == "v1"
mock_run_remote.assert_called_once()


@mock.patch("flytekit.configuration.plugin.FlyteRemote", spec=FlyteRemote)
@mock.patch("flytekit.clis.sdk_in_container.run.run_remote")
def test_remote_workflow_with_optional_arg(mock_run_remote, mock_remote):
@task()
def example_task(x: Optional[str]) -> str:
if x is None:
return ""
return f"{x}"

@workflow
def example_workflow(x: Optional[str]) -> str:
return example_task(x=x)

mock_remote_instance = mock.MagicMock()
mock_remote.return_value = mock_remote_instance
mock_remote_instance.fetch_workflow.return_value = example_workflow

runner = CliRunner()
result = runner.invoke(
pyflyte.main,
["run", "remote-workflow", "some_module.example_workflow"],
catch_exceptions=False,
)

assert result.exit_code == 0
mock_remote_instance.fetch_workflow.assert_called_once()
mock_run_remote.assert_called_once()
Loading