Skip to content

Commit

Permalink
fix the dbt deps cleanup
Browse files Browse the repository at this point in the history
dbt clean does not clean the modules path
shutil.rmtree does :)
bump test timeouts
  • Loading branch information
Jacob Beck committed Oct 21, 2019
1 parent 5cd8cff commit be1c6f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 10 additions & 2 deletions core/dbt/task/rpc/deps.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import os
import shutil

from .cli import HasCLI
from dbt.contracts.rpc import (
RPCNoParameters, RemoteEmptyResult, RemoteMethodFlags,
)
from dbt.task.clean import CleanTask
from dbt.task.deps import DepsTask


def _clean_deps(config):
modules_dir = os.path.join(config.project_root, config.modules_path)
if os.path.exists(modules_dir):
shutil.rmtree(modules_dir)
os.makedirs(modules_dir)


class RemoteDepsTask(HasCLI[RPCNoParameters, RemoteEmptyResult], DepsTask):
METHOD_NAME = 'deps'

Expand All @@ -20,6 +28,6 @@ def set_args(self, params: RPCNoParameters):
pass

def handle_request(self) -> RemoteEmptyResult:
CleanTask(self.args, self.config).run()
_clean_deps(self.config)
self.run()
return RemoteEmptyResult([])
14 changes: 9 additions & 5 deletions test/integration/048_rpc_test/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,15 @@ def poll_for_result(self, request_token, request_id=1, timeout=60, status='succe
.format(delta, status, result)
)

def async_query(self, _method, _sql=None, _test_request_id=1, macros=None, **kwargs):
def async_query(self, _method, _sql=None, _test_request_id=1, _poll_timeout=60, macros=None, **kwargs):
response = self.query(_method, _sql, _test_request_id, macros, **kwargs).json()
result = self.assertIsResult(response, _test_request_id)
self.assertIn('request_token', result)
return self.poll_for_result(result['request_token'], _test_request_id)
return self.poll_for_result(
result['request_token'],
request_id=_test_request_id,
timeout=_poll_timeout,
)

def query(self, _method, _sql=None, _test_request_id=1, macros=None, **kwargs):
built = self.build_query(_method, kwargs, _sql, _test_request_id, macros)
Expand Down Expand Up @@ -1145,7 +1149,7 @@ def test_deps_compilation_postgres(self):
status = self._check_start_predeps()

# do a dbt deps, wait for the result
self.assertIsResult(self.async_query('deps').json())
self.assertIsResult(self.async_query('deps', _poll_timeout=120).json())

self._check_deps_ok(status)

Expand All @@ -1154,7 +1158,7 @@ def test_deps_cli_compilation_postgres(self):
status = self._check_start_predeps()

# do a dbt deps, wait for the result
self.assertIsResult(self.async_query('cli_args', cli='deps').json())
self.assertIsResult(self.async_query('cli_args', cli='deps', _poll_timeout=120).json())

self._check_deps_ok(status)

Expand Down Expand Up @@ -1203,4 +1207,4 @@ def test_postgres_status_error(self):
self.assertIn('Invalid test config', str(data['message']))

# deps should work
self.assertIsResult(self.async_query('deps').json())
self.assertIsResult(self.async_query('deps', _poll_timeout=120).json())

0 comments on commit be1c6f5

Please sign in to comment.