Esempio n. 1
0
    def write_manifest_file(self, manifest):
        """Write the manifest file to disk.

        manifest should be a Manifest.
        """
        filename = manifest_file_name
        manifest_path = os.path.join(self.project['target-path'], filename)
        write_json(manifest_path, manifest.serialize())
Esempio n. 2
0
    def run(self):
        compile_results = None
        if self.args.compile:
            compile_results = super(GenerateTask, self).run()
            if any(r.error is not None for r in compile_results):
                dbt.ui.printer.print_timestamped_line(
                    'compile failed, cannot generate docs'
                )
                return {'compile_results': compile_results}

        shutil.copyfile(
            DOCS_INDEX_FILE_PATH,
            os.path.join(self.config.target_path, 'index.html'))

        manifest = self._get_manifest()
        adapter = get_adapter(self.config)

        dbt.ui.printer.print_timestamped_line("Building catalog")
        results = adapter.get_catalog(manifest)

        results = [
            dict(zip(results.column_names, row))
            for row in results
        ]

        nested_results = unflatten(results)
        results = {
            'nodes': incorporate_catalog_unique_ids(nested_results, manifest),
            'generated_at': dbt.utils.timestring(),
        }

        path = os.path.join(self.config.target_path, CATALOG_FILENAME)
        write_json(path, results)

        dbt.ui.printer.print_timestamped_line(
            'Catalog written to {}'.format(os.path.abspath(path))
        )
        # now that we've serialized the data we can add compile_results in to
        # make interpret_results happy.
        results['compile_results'] = compile_results

        return results
Esempio n. 3
0
    def run(self):
        compile_results = None
        if self.args.compile:
            compile_results = super(GenerateTask, self).run()
            if any(r.errored for r in compile_results):
                dbt.ui.printer.print_timestamped_line(
                    'compile failed, cannot generate docs')
                return {'compile_results': compile_results}

        shutil.copyfile(
            DOCS_INDEX_FILE_PATH,
            os.path.join(self.project['target-path'], 'index.html'))

        manifest = self._get_manifest()
        profile = self.project.run_environment()
        adapter = get_adapter(profile)

        dbt.ui.printer.print_timestamped_line("Building catalog")
        results = adapter.get_catalog(profile, self.project.cfg, manifest)

        results = [dict(zip(results.column_names, row)) for row in results]

        nested_results = unflatten(results)
        results = {
            'nodes': incorporate_catalog_unique_ids(nested_results, manifest),
            'generated_at': dbt.utils.timestring(),
        }

        path = os.path.join(self.project['target-path'], CATALOG_FILENAME)
        write_json(path, results)

        dbt.ui.printer.print_timestamped_line('Catalog written to {}'.format(
            os.path.abspath(path)))
        # now that we've serialized the data we can add compile_results in to
        # make interpret_results happy.
        results['compile_results'] = compile_results

        return results
Esempio n. 4
0
 def write(self, path: str, omit_none: bool = False):
     write_json(path, self.to_dict(omit_none=omit_none))  # type: ignore
Esempio n. 5
0
 def write_results(self, execution_result):
     filepath = os.path.join(self.project['target-path'], RESULT_FILE_NAME)
     write_json(filepath, execution_result.serialize())
Esempio n. 6
0
 def write_results(self, execution_result):
     filepath = os.path.join(self.config.target_path, RESULT_FILE_NAME)
     write_json(filepath, execution_result.serialize())
Esempio n. 7
0
 def write(self, path):
     write_json(path, self.serialize())
Esempio n. 8
0
 def write(self, path: str):
     write_json(path, self.to_dict(omit_none=False))