Skip to content

Commit

Permalink
Merge pull request #2093 from fishtown-analytics/fix/generate-no-compile
Browse files Browse the repository at this point in the history
fix --no-compile flag for docs generate
  • Loading branch information
beckjake authored Feb 6, 2020
2 parents 032d77d + da74681 commit 140cfd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
17 changes: 13 additions & 4 deletions core/dbt/task/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from dbt.exceptions import InternalException
from dbt.include.global_project import DOCS_INDEX_FILE_PATH
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.perf_utils import get_full_manifest
import dbt.ui.printer
import dbt.utils
import dbt.compilation
Expand Down Expand Up @@ -187,7 +188,7 @@ def _get_manifest(self) -> Manifest:
)
return self.manifest

def run(self):
def run(self) -> CatalogResults:
compile_results = None
if self.args.compile:
compile_results = CompileTask.run(self)
Expand All @@ -196,8 +197,13 @@ def run(self):
'compile failed, cannot generate docs'
)
return CatalogResults(
{}, datetime.utcnow(), compile_results, None
nodes={},
generated_at=datetime.utcnow(),
errors=None,
_compile_results=compile_results
)
else:
self.manifest = get_full_manifest(self.config)

shutil.copyfile(
DOCS_INDEX_FILE_PATH,
Expand Down Expand Up @@ -233,7 +239,8 @@ def run(self):

path = os.path.join(self.config.target_path, CATALOG_FILENAME)
results.write(path)
write_manifest(self.config, self.manifest)
if self.args.compile:
write_manifest(self.config, self.manifest)

if exceptions:
logger.error(
Expand Down Expand Up @@ -261,7 +268,9 @@ def get_catalog_results(
errors=errors,
)

def interpret_results(self, results):
def interpret_results(self, results: Optional[CatalogResults]) -> bool:
if results is None:
return False
if results.errors:
return False
compile_results = results._compile_results
Expand Down
13 changes: 11 additions & 2 deletions test/integration/029_docs_generate_tests/test_docs_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def project_config(self):
}
}

def run_and_generate(self, extra=None, seed_count=1, model_count=1, alternate_db=None):
def run_and_generate(self, extra=None, seed_count=1, model_count=1, alternate_db=None, args=None):
if alternate_db is None:
alternate_db = self.alternative_database
project = {
Expand All @@ -150,7 +150,10 @@ def run_and_generate(self, extra=None, seed_count=1, model_count=1, alternate_db
os.remove(normalize('target/manifest.json'))
os.remove(normalize('target/run_results.json'))
self.generate_start_time = datetime.utcnow()
self.run_dbt(['docs', 'generate', vars_arg])
base_args = ['docs', 'generate', vars_arg]
if args:
base_args.extend(args)
self.run_dbt(base_args)

def _no_stats(self):
return {
Expand Down Expand Up @@ -3393,6 +3396,12 @@ def verify_run_results(self, expected_run_results):
run_result['results'].sort(key=lambda r: r['node']['unique_id'])
self.assertEqual(run_result['results'], expected_run_results)

@use_profile('postgres')
def test__postgres__run_and_generate_no_compile(self):
self.run_and_generate(alternate_db=self.default_database, args=['--no-compile'])
self.verify_catalog(self.expected_postgres_catalog())
self.assertFalse(os.path.exists('./target/manifest.json'))

@use_profile('postgres')
def test__postgres__run_and_generate(self):
self.run_and_generate(alternate_db=self.default_database)
Expand Down

0 comments on commit 140cfd7

Please sign in to comment.