Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix execution of "defer" command for dbt-core 1.4 #149

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions dbt_rpc/contracts/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -102,6 +103,7 @@ class RPCTestParameters(RPCCompileParameters):
schema: bool = False
state: Optional[str] = None
defer: Optional[bool] = None
favor_state: Optional[bool] = None


@dataclass
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dbt_rpc/rpc/task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions dbt_rpc/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -34,13 +33,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:
Expand Down
5 changes: 4 additions & 1 deletion dbt_rpc/task/cli.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
8 changes: 8 additions & 0 deletions dbt_rpc/task/project_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Loading