From be1c6f5e5a2711dca847ee5b7cd1cb859814553d Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Sun, 20 Oct 2019 08:45:35 -0600 Subject: [PATCH] fix the dbt deps cleanup dbt clean does not clean the modules path shutil.rmtree does :) bump test timeouts --- core/dbt/task/rpc/deps.py | 12 ++++++++++-- test/integration/048_rpc_test/test_rpc.py | 14 +++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/dbt/task/rpc/deps.py b/core/dbt/task/rpc/deps.py index 22f7cc478ed..41cf101bbd9 100644 --- a/core/dbt/task/rpc/deps.py +++ b/core/dbt/task/rpc/deps.py @@ -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' @@ -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([]) diff --git a/test/integration/048_rpc_test/test_rpc.py b/test/integration/048_rpc_test/test_rpc.py index 546915d8e34..b9bb0f81a96 100644 --- a/test/integration/048_rpc_test/test_rpc.py +++ b/test/integration/048_rpc_test/test_rpc.py @@ -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) @@ -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) @@ -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) @@ -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())