Repository: dbt-labs/dbt-core

Issue:
dbt clean regression
### Describe the bug
In dbt 0.16.1 `dbt clean` fails without a profile: 

```bash
(dbt) dbt$ dbt --version
installed version: 0.16.1
   latest version: 0.17.0

Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
(dbt) dbt$ dbt clean
Running with dbt=0.16.1
Encountered an error while reading the project:
  ERROR: Runtime Error
  Could not find profile named 'profile'
Encountered an error:
Runtime Error
  Could not run dbt
```

In dbt 0.15.1, `dbt clean` works.

```bash
(dbt) dbt$ dbt --version
installed version: 0.15.1
   latest version: 0.17.0

Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
(dbt) dbt$ dbt clean
Running with dbt=0.15.1
Checking target/*
 Cleaned target/*
Finished cleaning all paths.
```

### Steps To Reproduce
Delete any profile found in `~/.dbt/profile.yml`. 

Install 0.16.1:
```bash
pip install dbt==0.16.1
```
Navigate to dbt project:
```
dbt clean
```

Repeat for 0.15.1 to confirm regression.

### Expected behavior
I expected `dbt clean` to work without a profile. This broke some of our automated jobs when we tried to upgrade.

### System information
**Which database are you using dbt with?**
- [ ] postgres
- [X] redshift
- [ ] bigquery
- [ ] snowflake
- [ ] other (specify: ____________)


**The output of `dbt --version`:**
Multiple versions. See above.

**The operating system you're using:**
macOS 10.14.6

**The output of `python --version`:**
```
(dbt) dbt$ python --version
Python 3.7.3
```

### Additional context
Most people probably don't run `dbt clean` without a profile, but it was causing us confusion, so wanted to document it as a breaking change at least.

I also tested this with 0.17.0: same error as 0.16.1.

```
(dbt) dbt$ dbt --version
installed version: 0.17.0
   latest version: 0.17.0

Up to date!

Plugins:
  - bigquery: 0.17.0
  - snowflake: 0.17.0
  - redshift: 0.17.0
  - postgres: 0.17.0
(dbt) dbt$ dbt clean
Running with dbt=0.17.0
Encountered an error while reading the project:
  ERROR: Runtime Error
  Could not find profile named 'profile'
Encountered an error:
Runtime Error
  Could not run dbt
```



Discussion:
Thanks for pointing this out, @tmastny. You're right that it's a regression.

We removed the profile requirement for `dbt deps` in 0.16.1 (https://github.com/fishtown-analytics/dbt/issues/2231), but it seems like we didn't fix it for `dbt clean`.

Resolving patch:
diff --git a/core/dbt/task/clean.py b/core/dbt/task/clean.py
--- 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('.')


Test patch:
diff --git a/test/integration/006_simple_dependency_test/test_simple_dependency.py b/test/integration/006_simple_dependency_test/test_simple_dependency.py
--- 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