Skip to content

Commit

Permalink
clean without a profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Jul 27, 2020
1 parent a1c2270 commit de4f90b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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), [#2649](https://github.com/fishtown-analytics/dbt/pull/2649))

Contributors:
- [@joshpeng-quibi](https://github.com/joshpeng-quibi) ([#2646](https://github.com/fishtown-analytics/dbt/pull/2646))
Expand Down
6 changes: 4 additions & 2 deletions core/dbt/task/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import shutil
import tempfile
from test.integration.base import DBTIntegrationTest, use_profile
from dbt.exceptions import CompilationException
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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):
Expand Down Expand Up @@ -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

0 comments on commit de4f90b

Please sign in to comment.