예제 #1
0
def print_compile_stats(stats):
    names = {
        NodeType.Model: 'model',
        NodeType.Test: 'test',
        NodeType.Snapshot: 'snapshot',
        NodeType.Analysis: 'analysis',
        NodeType.Macro: 'macro',
        NodeType.Operation: 'operation',
        NodeType.Seed: 'seed file',
        NodeType.Source: 'source',
        NodeType.Exposure: 'exposure',
    }

    results = {k: 0 for k in names.keys()}
    results.update(stats)

    # create tracking event for resource_counts
    if dbt.tracking.active_user is not None:
        resource_counts = {k.pluralize(): v for k, v in results.items()}
        dbt.tracking.track_resource_counts(resource_counts)

    stat_line = ", ".join([
        pluralize(ct, names.get(t)) for t, ct in results.items() if t in names
    ])

    logger.info("Found {}".format(stat_line))
예제 #2
0
def print_end_of_run_summary(num_errors: int,
                             num_warnings: int,
                             keyboard_interrupt: bool = False) -> None:
    error_plural = utils.pluralize(num_errors, 'error')
    warn_plural = utils.pluralize(num_warnings, 'warning')
    if keyboard_interrupt:
        message = ui.yellow('Exited because of keyboard interrupt.')
    elif num_errors > 0:
        message = ui.red("Completed with {} and {}:".format(
            error_plural, warn_plural))
    elif num_warnings > 0:
        message = ui.yellow('Completed with {}:'.format(warn_plural))
    else:
        message = ui.green('Completed successfully')

    with TextOnly():
        logger.info('')
    logger.info('{}'.format(message))
예제 #3
0
def get_counts(flat_nodes) -> str:
    counts: Dict[str, int] = {}

    for node in flat_nodes:
        t = node.resource_type

        if node.resource_type == NodeType.Model:
            t = '{} {}'.format(node.get_materialization(), t)
        elif node.resource_type == NodeType.Operation:
            t = 'hook'

        counts[t] = counts.get(t, 0) + 1

    stat_line = ", ".join([utils.pluralize(v, k) for k, v in counts.items()])

    return stat_line
예제 #4
0
def print_run_result_error(result,
                           newline: bool = True,
                           is_warning: bool = False) -> None:
    if newline:
        with TextOnly():
            logger.info("")

    if result.status == NodeStatus.Fail or (is_warning and result.status
                                            == NodeStatus.Warn):
        if is_warning:
            color = ui.yellow
            info = 'Warning'
            logger_fn = logger.warning
        else:
            color = ui.red
            info = 'Failure'
            logger_fn = logger.error
        logger_fn(
            color("{} in {} {} ({})").format(info, result.node.resource_type,
                                             result.node.name,
                                             result.node.original_file_path))

        try:
            # if message is int, must be rows returned for a test
            int(result.message)
        except ValueError:
            logger.error("  Status: {}".format(result.status))
        else:
            num_rows = utils.pluralize(result.message, 'result')
            logger.error("  Got {}, expected 0.".format(num_rows))

        if result.node.build_path is not None:
            with TextOnly():
                logger.info("")
            logger.info("  compiled SQL at {}".format(result.node.build_path))

    elif result.message is not None:
        first = True
        for line in result.message.split("\n"):
            if first:
                logger.error(ui.yellow(line))
                first = False
            else:
                logger.error(line)
예제 #5
0
def print_compile_stats(stats):
    names = {
        NodeType.Model: 'model',
        NodeType.Test: 'test',
        NodeType.Snapshot: 'snapshot',
        NodeType.Analysis: 'analysis',
        NodeType.Macro: 'macro',
        NodeType.Operation: 'operation',
        NodeType.Seed: 'seed file',
        NodeType.Source: 'source',
    }

    results = {k: 0 for k in names.keys()}
    results.update(stats)

    stat_line = ", ".join([
        pluralize(ct, names.get(t)) for t, ct in results.items() if t in names
    ])

    logger.info("Found {}".format(stat_line))