From 0ce8c5800c5738ef8a69e15913f843eb1f77c7d0 Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Fri, 24 Jul 2020 14:56:27 -0600 Subject: [PATCH] clean without a profile --- CHANGELOG.md | 3 ++- core/dbt/task/clean.py | 6 +++-- .../test_simple_dependency.py | 22 ++++++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index caed4ad9287..b726ae55a4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ### Fixes -- fast-fail option with adapters that don't support cancelling queries will now passthrough the original error messages ([#2644](https://github.com/fishtown-analytics/dbt/issues/2644)) +- fast-fail option with adapters that don't support cancelling queries will now passthrough the original error messages ([#2644](https://github.com/fishtown-analytics/dbt/issues/2644), [#2646](https://github.com/fishtown-analytics/dbt/pull/2646)) +- `dbt clean` no longer requries a profile ([#2620](https://github.com/fishtown-analytics/dbt/issues/2620), [#2648](https://github.com/fishtown-analytics/dbt/pull/2648)) Contributors: - [@joshpeng-quibi](https://github.com/joshpeng-quibi) ([#2646](https://github.com/fishtown-analytics/dbt/pull/2646)) diff --git a/core/dbt/task/clean.py b/core/dbt/task/clean.py index 84ef9b63532..8632c6e29e2 100644 --- a/core/dbt/task/clean.py +++ b/core/dbt/task/clean.py @@ -2,11 +2,13 @@ import os import shutil -from dbt.task.base import ConfiguredTask +from dbt.task.base import BaseTask from dbt.logger import GLOBAL_LOGGER as logger +from dbt.config import UnsetProfileConfig -class CleanTask(ConfiguredTask): +class CleanTask(BaseTask): + ConfigType = UnsetProfileConfig def __is_project_path(self, path): proj_path = os.path.abspath('.') diff --git a/test/integration/006_simple_dependency_test/test_simple_dependency.py b/test/integration/006_simple_dependency_test/test_simple_dependency.py index 837590c0265..28ce6244b63 100644 --- a/test/integration/006_simple_dependency_test/test_simple_dependency.py +++ b/test/integration/006_simple_dependency_test/test_simple_dependency.py @@ -1,5 +1,4 @@ import os -import shutil import tempfile from test.integration.base import DBTIntegrationTest, use_profile from dbt.exceptions import CompilationException @@ -34,6 +33,9 @@ def packages_config(self): def run_deps(self): return self.run_dbt(["deps"]) + def run_clean(self): + return self.run_dbt(['clean']) + @use_profile('postgres') def test_postgres_simple_dependency(self): self.run_deps() @@ -56,6 +58,10 @@ def test_postgres_simple_dependency(self): self.assertTablesEqual("seed", "view_model") self.assertTablesEqual("seed", "incremental") + assert os.path.exists('target') + self.run_clean() + assert not os.path.exists('target') + @use_profile('postgres') def test_postgres_simple_dependency_with_models(self): self.run_deps() @@ -73,6 +79,10 @@ def test_postgres_simple_dependency_with_models(self): self.assertEqual(created_models['view_model'], 'view') self.assertEqual(created_models['view_summary'], 'view') + assert os.path.exists('target') + self.run_clean() + assert not os.path.exists('target') + class TestSimpleDependencyUnpinned(DBTIntegrationTest): def setUp(self): @@ -234,9 +244,11 @@ def test_postgres_empty_models_not_compiled_in_dependencies(self): class TestSimpleDependencyNoProfile(TestSimpleDependency): def run_deps(self): - tmpdir = tempfile.mkdtemp() - try: + with tempfile.TemporaryDirectory() as tmpdir: result = self.run_dbt(["deps", "--profiles-dir", tmpdir]) - finally: - shutil.rmtree(tmpdir) + return result + + def run_clean(self): + with tempfile.TemporaryDirectory() as tmpdir: + result = self.run_dbt(["clean", "--profiles-dir", tmpdir]) return result