Skip to content

Commit

Permalink
Support - and _
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Newton <thomas.w.newton@gmail.com>
  • Loading branch information
Tom-Newton committed Sep 23, 2024
1 parent 604f07c commit 34466a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions flytekit/clis/sdk_in_container/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ def to_click_option(
required = False if default_val and isinstance(default_val, ArtifactQuery) else required

if literal_converter.is_bool():
click_cli_paramater_name = f"--{input_name}/--no_{input_name}"
click_cli_parameter_names = [f"--{input_name}/--no_{input_name}", f"--{input_name}/--no-{input_name.replace('_', '-')}"]
else:
click_cli_paramater_name = f"--{input_name}"
click_cli_parameter_names = [f"--{input_name}"]

return click.Option(
param_decls=[click_cli_paramater_name],
param_decls=click_cli_parameter_names,
type=literal_converter.click_type,
default=default_val,
show_default=True,
Expand Down
15 changes: 9 additions & 6 deletions tests/flytekit/unit/cli/pyflyte/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,19 @@ def test_union_type1(input):
@pytest.mark.parametrize(
"extra_cli_args, task_name, expected_output",
[
(("--a",), "test_boolean", True),
(("--no_a",), "test_boolean", False),
(("--a_b",), "test_boolean", True),
(("--no_a_b",), "test_boolean", False),
(("--no-a-b",), "test_boolean", False),
(tuple(), "test_boolean_default_true", True),
(("--a",), "test_boolean_default_true", True),
(("--no_a",), "test_boolean_default_true", False),
(("--a_b",), "test_boolean_default_true", True),
(("--no_a_b",), "test_boolean_default_true", False),
(("--no-a-b",), "test_boolean_default_true", False),
(tuple(), "test_boolean_default_false", False),
(("--a",), "test_boolean_default_false", True),
(("--no_a",), "test_boolean_default_false", False),
(("--a_b",), "test_boolean_default_false", True),
(("--no_a_b",), "test_boolean_default_false", False),
(("--no-a-b",), "test_boolean_default_false", False),
],
)
def test_boolean_type(extra_cli_args, task_name, expected_output):
Expand Down
12 changes: 6 additions & 6 deletions tests/flytekit/unit/cli/pyflyte/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ def test_union2(a: typing.Union[float, typing.List[int], MyDataclass]):
print(a)

@task
def test_boolean(a: bool):
print(a)
def test_boolean(a_b: bool):
print(a_b)

@task
def test_boolean_default_true(a: bool = True):
print(a)
def test_boolean_default_true(a_b: bool = True):
print(a_b)

@task
def test_boolean_default_false(a: bool = False):
print(a)
def test_boolean_default_false(a_b: bool = False):
print(a_b)


@workflow
Expand Down

0 comments on commit 34466a3

Please sign in to comment.