From c6898530c2f24872b7eb4fd2ac8278c7a40b66f1 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Wed, 2 Aug 2023 14:17:00 -0700 Subject: [PATCH 1/2] fix constructing param with 0 value --- .changes/unreleased/Fixes-20230802-141556.yaml | 6 ++++++ core/dbt/cli/flags.py | 5 ++--- tests/unit/test_cli_flags.py | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixes-20230802-141556.yaml diff --git a/.changes/unreleased/Fixes-20230802-141556.yaml b/.changes/unreleased/Fixes-20230802-141556.yaml new file mode 100644 index 00000000000..8b96ccab5c7 --- /dev/null +++ b/.changes/unreleased/Fixes-20230802-141556.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix retry not working with log-file-max-bytes +time: 2023-08-02T14:15:56.306027-07:00 +custom: + Author: ChenyuLInx + Issue: "8297" diff --git a/core/dbt/cli/flags.py b/core/dbt/cli/flags.py index df79ad5941b..8a60eae208b 100644 --- a/core/dbt/cli/flags.py +++ b/core/dbt/cli/flags.py @@ -61,7 +61,6 @@ def args_to_context(args: List[str]) -> Context: if len(args) == 1 and "," in args[0]: args = args[0].split(",") sub_command_name, sub_command, args = cli.resolve_command(cli_ctx, args) - # Handle source and docs group. if isinstance(sub_command, Group): sub_command_name, sub_command, args = sub_command.resolve_command(cli_ctx, args) @@ -319,7 +318,6 @@ def command_params(command: CliCommand, args_dict: Dict[str, Any]) -> CommandPar for k, v in args_dict.items(): k = k.lower() - # if a "which" value exists in the args dict, it should match the command provided if k == WHICH_KEY: if v != command.value: @@ -344,7 +342,8 @@ def add_fn(x): if k == "macro" and command == CliCommand.RUN_OPERATION: add_fn(v) - elif v in (None, False): + # None is Signletons, False is flyweight, only one instance of each. + elif v is None or v is False: add_fn(f"--no-{spinal_cased}") elif v is True: add_fn(f"--{spinal_cased}") diff --git a/tests/unit/test_cli_flags.py b/tests/unit/test_cli_flags.py index 8ff85dc144c..d5d78a229ae 100644 --- a/tests/unit/test_cli_flags.py +++ b/tests/unit/test_cli_flags.py @@ -391,3 +391,8 @@ def test_from_dict__which_fails(self): args_dict = {"which": "some bad command"} with pytest.raises(DbtInternalError, match=r"does not match value of which"): self._create_flags_from_dict(Command.RUN, args_dict) + + def test_from_dict_0_value(self): + args_dict = {"log_file_max_bytes": 0} + flags = Flags.from_dict(Command.RUN, args_dict) + assert flags.LOG_FILE_MAX_BYTES == 0 From fd57e2ac791abe3bbe38a2efb9ba8c7ea1230c87 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Wed, 2 Aug 2023 14:31:27 -0700 Subject: [PATCH 2/2] Update core/dbt/cli/flags.py Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> --- core/dbt/cli/flags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/cli/flags.py b/core/dbt/cli/flags.py index 8a60eae208b..863db6ed0e4 100644 --- a/core/dbt/cli/flags.py +++ b/core/dbt/cli/flags.py @@ -342,7 +342,7 @@ def add_fn(x): if k == "macro" and command == CliCommand.RUN_OPERATION: add_fn(v) - # None is Signletons, False is flyweight, only one instance of each. + # None is a Singleton, False is a Flyweight, only one instance of each. elif v is None or v is False: add_fn(f"--no-{spinal_cased}") elif v is True: