From 4b1f2996c32afb7f9cefd8265c29a84a9e4379fd Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Fri, 28 Jul 2023 09:38:07 -0400 Subject: [PATCH 1/3] Remove "defer_to_manifest" method from RPCTask --- dbt_rpc/task/base.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dbt_rpc/task/base.py b/dbt_rpc/task/base.py index c679c01..e84632a 100644 --- a/dbt_rpc/task/base.py +++ b/dbt_rpc/task/base.py @@ -34,13 +34,6 @@ def load_manifest(self): # we started out with a manifest! pass - def defer_to_manifest(self, adapter, selected_uids: AbstractSet[str]): - # https://github.com/dbt-labs/dbt-core/pull/6488 - # abstract method added to GraphRunnableTask - # bacause of how we do multiple inheritance for project commands, - # this will be overridden by task-specific methods - pass - def get_result( self, results, elapsed_time, generated_at ) -> RemoteExecutionResult: From 3f7252c50b49e8b1d2d5a1f8373380637d7cc7c0 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Tue, 1 Aug 2023 09:55:32 -0400 Subject: [PATCH 2/3] Add "favor_state" param to support defer --- dbt_rpc/contracts/rpc.py | 3 +++ dbt_rpc/task/cli.py | 5 ++++- dbt_rpc/task/project_commands.py | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dbt_rpc/contracts/rpc.py b/dbt_rpc/contracts/rpc.py index 31831a0..adedeae 100644 --- a/dbt_rpc/contracts/rpc.py +++ b/dbt_rpc/contracts/rpc.py @@ -85,6 +85,7 @@ class RPCRunParameters(RPCParameters): selector: Optional[str] = None state: Optional[str] = None defer: Optional[bool] = None + favor_state: Optional[bool] = None @dataclass @@ -102,6 +103,7 @@ class RPCTestParameters(RPCCompileParameters): schema: bool = False state: Optional[str] = None defer: Optional[bool] = None + favor_state: Optional[bool] = None @dataclass @@ -129,6 +131,7 @@ class RPCBuildParameters(RPCParameters): selector: Optional[str] = None state: Optional[str] = None defer: Optional[bool] = None + favor_state: Optional[bool] = None @dataclass diff --git a/dbt_rpc/task/cli.py b/dbt_rpc/task/cli.py index 68c9772..18fd41d 100644 --- a/dbt_rpc/task/cli.py +++ b/dbt_rpc/task/cli.py @@ -1,7 +1,7 @@ import abc import shlex from dbt.clients.yaml_helper import Dumper, yaml # noqa: F401 -from typing import Type, Optional +from typing import Type, Optional, AbstractSet from dbt.config.utils import parse_cli_vars @@ -125,3 +125,6 @@ def interpret_results(self, results): # failure return False return self.real_task.interpret_results(results) + + def defer_to_manifest(self, adapter, selected_uids: AbstractSet[str]): + return self.real_task.defer_to_manifest(self, adapter, selected_uids) diff --git a/dbt_rpc/task/project_commands.py b/dbt_rpc/task/project_commands.py index bf2162f..d854e00 100644 --- a/dbt_rpc/task/project_commands.py +++ b/dbt_rpc/task/project_commands.py @@ -110,6 +110,10 @@ def set_args(self, params: RPCRunParameters) -> None: self.args.defer = flags.DEFER_MODE else: self.args.defer = params.defer + if params.favor_state is None: + self.args.favor_state = False + else: + self.args.favor_state = params.favor_state self.args.state = state_path(params.state) self.set_previous_state() @@ -335,6 +339,10 @@ def set_args(self, params: RPCBuildParameters) -> None: self.args.defer = flags.DEFER_MODE else: self.args.defer = params.defer + if params.favor_state is None: + self.args.favor_state = False + else: + self.args.favor_state = params.favor_state self.args.state = state_path(params.state) self.set_previous_state() From 94fc1949d68b22502a2f313adbc8390bd746b60e Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 2 Aug 2023 11:35:37 -0400 Subject: [PATCH 3/3] flake8 --- dbt_rpc/rpc/task_handler.py | 2 +- dbt_rpc/task/base.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dbt_rpc/rpc/task_handler.py b/dbt_rpc/rpc/task_handler.py index f615ddd..02bd81f 100644 --- a/dbt_rpc/rpc/task_handler.py +++ b/dbt_rpc/rpc/task_handler.py @@ -83,7 +83,7 @@ def _spawn_setup(self): def task_exec(self) -> None: """task_exec runs first inside the child process""" - if type(self.task) != RemoteListTask: + if type(self.task) is not RemoteListTask: # TODO: find another solution for this.. in theory it stops us from # being able to kill RemoteListTask processes signal.signal(signal.SIGTERM, sigterm_handler) diff --git a/dbt_rpc/task/base.py b/dbt_rpc/task/base.py index e84632a..74a2e1b 100644 --- a/dbt_rpc/task/base.py +++ b/dbt_rpc/task/base.py @@ -10,7 +10,6 @@ ) from dbt.task.runnable import GraphRunnableTask from dbt_rpc.rpc.method import RemoteManifestMethod, Parameters -from typing import AbstractSet RESULT_TYPE_MAP = {