コード例 #1
0
    def print_results_line(self, results, execution_time):
        nodes = [r.node for r in results] + self.ran_hooks
        stat_line = get_counts(nodes)

        execution = ""

        if execution_time is not None:
            execution = " in {execution_time:0.2f}s".format(
                execution_time=execution_time)

        print_timestamped_line("")
        print_timestamped_line(
            "Finished running {stat_line}{execution}.".format(
                stat_line=stat_line, execution=execution))
コード例 #2
0
    def run_hooks(self, adapter, hook_type: RunHookType, extra_context):
        ordered_hooks = self.get_hooks_by_type(hook_type)

        # on-run-* hooks should run outside of a transaction. This happens
        # b/c psycopg2 automatically begins a transaction when a connection
        # is created.
        adapter.clear_transaction()
        if not ordered_hooks:
            return
        num_hooks = len(ordered_hooks)

        plural = 'hook' if num_hooks == 1 else 'hooks'
        with TextOnly():
            print_timestamped_line("")
        print_timestamped_line('Running {} {} {}'.format(
            num_hooks, hook_type, plural))
        startctx = TimestampNamed('node_started_at')
        finishctx = TimestampNamed('node_finished_at')

        for idx, hook in enumerate(ordered_hooks, start=1):
            sql = self.get_hook_sql(adapter, hook, idx, num_hooks,
                                    extra_context)

            hook_text = '{}.{}.{}'.format(hook.package_name, hook_type,
                                          hook.index)
            hook_meta_ctx = HookMetadata(hook, self.index_offset(idx))
            with UniqueID(hook.unique_id):
                with hook_meta_ctx, startctx:
                    print_hook_start_line(hook_text, idx, num_hooks)

                status = 'OK'

                with Timer() as timer:
                    if len(sql.strip()) > 0:
                        status, _ = adapter.execute(sql,
                                                    auto_begin=False,
                                                    fetch=False)
                self.ran_hooks.append(hook)

                with finishctx, DbtModelState({'node_status': 'passed'}):
                    print_hook_end_line(hook_text, status, idx, num_hooks,
                                        timer.elapsed)

        self._total_executed += len(ordered_hooks)

        with TextOnly():
            print_timestamped_line("")
コード例 #3
0
    def run_hooks(self, adapter, hook_type, extra_context):
        ordered_hooks = self.get_hooks_by_type(hook_type)

        # on-run-* hooks should run outside of a transaction. This happens
        # b/c psycopg2 automatically begins a transaction when a connection
        # is created.
        adapter.clear_transaction()
        if not ordered_hooks:
            return
        num_hooks = len(ordered_hooks)

        plural = 'hook' if num_hooks == 1 else 'hooks'
        print_timestamped_line("")
        print_timestamped_line('Running {} {} {}'.format(
            num_hooks, hook_type, plural))

        for idx, hook in enumerate(ordered_hooks, start=1):
            sql = self.get_hook_sql(adapter, hook, idx, num_hooks,
                                    extra_context)

            hook_text = '{}.{}.{}'.format(hook.package_name, hook_type,
                                          hook.index)
            print_hook_start_line(hook_text, idx, num_hooks)
            status = 'OK'

            with Timer() as timer:
                if len(sql.strip()) > 0:
                    status, _ = adapter.execute(sql,
                                                auto_begin=False,
                                                fetch=False)
            self.ran_hooks.append(hook)

            print_hook_end_line(hook_text, status, idx, num_hooks,
                                timer.elapsed)

        print_timestamped_line("")
コード例 #4
0
ファイル: freshness.py プロジェクト: analyst-collective/dbt
    def task_end_messages(self, results):
        for result in results:
            if result.error is not None:
                print_run_result_error(result)

        print_timestamped_line('Done.')
コード例 #5
0
    def task_end_messages(self, results):
        for result in results:
            if result.error is not None:
                print_run_result_error(result)

        print_timestamped_line('Done.')