Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix --no-compile flag for docs generate #2093

Merged
merged 2 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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