<commit_before>from abc import ABCMeta, abstractmethod
import os

import six

from dbt.config import RuntimeConfig, Project
from dbt.config.profile import read_profile, PROFILES_DIR
from dbt import flags
from dbt import tracking
from dbt.logger import GLOBAL_LOGGER as logger
import dbt.exceptions


class NoneConfig(object):
    @classmethod
    def from_args(cls, args):
        return None


def read_profiles(profiles_dir=None):
    """This is only used for some error handling"""
    if profiles_dir is None:
        profiles_dir = PROFILES_DIR

    raw_profiles = read_profile(profiles_dir)

    if raw_profiles is None:
        profiles = {}
    else:
        profiles = {k: v for (k, v) in raw_profiles.items() if k != 'config'}

    return profiles


PROFILES_HELP_MESSAGE = """
For more information on configuring profiles, please consult the dbt docs:

https://docs.getdbt.com/docs/configure-your-profile
"""


@six.add_metaclass(ABCMeta)
class BaseTask(object):
    ConfigType = NoneConfig

    def __init__(self, args, config):
        self.args = args
        self.config = config

    @classmethod
    def from_args(cls, args):
        try:
            config = cls.ConfigType.from_args(args)
        except DbtProjectError as exc:
            logger.info("Encountered an error while reading the project:")
            logger.info(to_string(exc))

            tracking.track_invalid_invocation(
                args=args,
                result_type=exc.result_type)
            raise dbt.exceptions.RuntimeException('Could not run dbt')
        except DbtProfileError as exc:
            logger.info("Encountered an error while reading profiles:")
            logger.info("  ERROR {}".format(str(exc)))<commit_msg>fix an error handling bug I introduced<commit_after>from abc import ABCMeta, abstractmethod
import os

import six

from dbt.config import RuntimeConfig, Project
from dbt.config.profile import read_profile, PROFILES_DIR
from dbt import flags
from dbt import tracking
from dbt.logger import GLOBAL_LOGGER as logger
import dbt.exceptions


class NoneConfig(object):
    @classmethod
    def from_args(cls, args):
        return None


def read_profiles(profiles_dir=None):
    """This is only used for some error handling"""
    if profiles_dir is None:
        profiles_dir = PROFILES_DIR

    raw_profiles = read_profile(profiles_dir)

    if raw_profiles is None:
        profiles = {}
    else:
        profiles = {k: v for (k, v) in raw_profiles.items() if k != 'config'}

    return profiles


PROFILES_HELP_MESSAGE = """
For more information on configuring profiles, please consult the dbt docs:

https://docs.getdbt.com/docs/configure-your-profile
"""


@six.add_metaclass(ABCMeta)
class BaseTask(object):
    ConfigType = NoneConfig

    def __init__(self, args, config):
        self.args = args
        self.config = config

    @classmethod
    def from_args(cls, args):
        try:
            config = cls.ConfigType.from_args(args)
        except dbt.exceptions.DbtProjectError as exc:
            logger.info("Encountered an error while reading the project:")
            logger.info(to_string(exc))

            tracking.track_invalid_invocation(
                args=args,
                result_type=exc.result_type)
            raise dbt.exceptions.RuntimeException('Could not run dbt')
        except dbt.exceptions.DbtProfileError as exc:
            logger.info("Encountered an error while reading profiles:")
            logger.info("  ERROR {}".format(str(exc)))
{'fraction_non_alphanumeric': 0.08250355618776671, 'fraction_numerical': 0.0, 'mean_word_length': 2.946127946127946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4187521', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1020, 'n_words': 297}