<commit_before>from __future__ import division
import json
import inspect
import copy
from functools import wraps
import traceback
import warnings
import logging
import datetime
from six import PY3, string_types
from collections import namedtuple

from collections import (
    Counter,
    defaultdict
)

from great_expectations.version import __version__
from great_expectations.data_asset.util import (
    recursively_convert_to_json_serializable,
    parse_result_format,
    get_empty_expectation_suite
)
from great_expectations.types import DotDict

logger = logging.getLogger(__name__)
logging.captureWarnings(True)


class DataAsset(object):

    # This should in general only be changed when a subclass *adds expectations* or *changes expectation semantics*
    # That way, multiple backends can implement the same data_asset_type
    _data_asset_type = "DataAsset"

    def __init__(self, *args, **kwargs):
        """
        Initialize the DataAsset.

        :param profiler (profiler class) = None: The profiler that should be run on the data_asset to
            build a baseline expectation suite.

        Note: DataAsset is designed to support multiple inheritance (e.g. PandasDataset inherits from both a
        Pandas DataFrame and Dataset which inherits from DataAsset), so it accepts generic *args and **kwargs arguments
        so that they can also be passed to other parent classes. In python 2, there isn't a clean way to include all of
        *args, **kwargs, and a named kwarg...so we use the inelegant solution of popping from kwargs, leaving the
        support for the profiler parameter not obvious from the signature.

        """
        interactive_evaluation = kwargs.pop("interactive_evaluation", True)
        profiler = kwargs.pop("profiler", None)
        expectation_suite = kwargs.pop("expectation_suite", None)
        data_asset_name = kwargs.pop("data_asset_name", None)
        expectation_suite_name = kwargs.pop("expectation_suite_name", None)
        data_context = kwargs.pop("data_context", None)
        batch_kwargs = kwargs.pop("batch_kwargs", None)
        if "autoinspect_func" in kwargs:
            warnings.warn("Autoinspect_func is no longer supported; use a profiler instead (migration is easy!).",
                          category=DeprecationWarning)
        super(DataAsset, self).__init__(*args, **kwargs)
        self._config = {
            "interactive_evaluation": interactive_evaluation
        }
        self._initialize_expectations(
            expectation_suite=expectation_suite,
            data_asset_name=data_asset_name,
            expectation_suite_name=expectation_suite_name
        )
        self._data_context = data_context
        self._batch_kwargs = batch_kwargs

        if profiler is not None:
            profiler.profile(self)
        if data_context and hasattr(data_context, '_expectation_explorer_manager'):
            self.set_default_expectation_argument("include_config", True)

    def autoinspect(self, profiler):<commit_msg>Allow a specific batch_id in addition to batch_kwargs on data_asset   - in the future, we may consolidate this<commit_after>from __future__ import division
import json
import inspect
import copy
from functools import wraps
import traceback
import warnings
import logging
import datetime
from six import PY3, string_types
from collections import namedtuple

from collections import (
    Counter,
    defaultdict
)

from great_expectations.version import __version__
from great_expectations.data_asset.util import (
    recursively_convert_to_json_serializable,
    parse_result_format,
    get_empty_expectation_suite
)
from great_expectations.types import DotDict

logger = logging.getLogger(__name__)
logging.captureWarnings(True)


class DataAsset(object):

    # This should in general only be changed when a subclass *adds expectations* or *changes expectation semantics*
    # That way, multiple backends can implement the same data_asset_type
    _data_asset_type = "DataAsset"

    def __init__(self, *args, **kwargs):
        """
        Initialize the DataAsset.

        :param profiler (profiler class) = None: The profiler that should be run on the data_asset to
            build a baseline expectation suite.

        Note: DataAsset is designed to support multiple inheritance (e.g. PandasDataset inherits from both a
        Pandas DataFrame and Dataset which inherits from DataAsset), so it accepts generic *args and **kwargs arguments
        so that they can also be passed to other parent classes. In python 2, there isn't a clean way to include all of
        *args, **kwargs, and a named kwarg...so we use the inelegant solution of popping from kwargs, leaving the
        support for the profiler parameter not obvious from the signature.

        """
        interactive_evaluation = kwargs.pop("interactive_evaluation", True)
        profiler = kwargs.pop("profiler", None)
        expectation_suite = kwargs.pop("expectation_suite", None)
        data_asset_name = kwargs.pop("data_asset_name", None)
        expectation_suite_name = kwargs.pop("expectation_suite_name", None)
        data_context = kwargs.pop("data_context", None)
        batch_kwargs = kwargs.pop("batch_kwargs", None)
        batch_id = kwargs.pop("batch_id", None)

        if "autoinspect_func" in kwargs:
            warnings.warn("Autoinspect_func is no longer supported; use a profiler instead (migration is easy!).",
                          category=DeprecationWarning)
        super(DataAsset, self).__init__(*args, **kwargs)
        self._config = {
            "interactive_evaluation": interactive_evaluation
        }
        self._initialize_expectations(
            expectation_suite=expectation_suite,
            data_asset_name=data_asset_name,
            expectation_suite_name=expectation_suite_name
        )
        self._data_context = data_context
        self._batch_kwargs = batch_kwargs
        self._batch_id = batch_id

        if profiler is not None:
            profiler.profile(self)
        if data_context and hasattr(data_context, '_expectation_explorer_manager'):
            self.set_default_expectation_argument("include_config", True)

    def autoinspect(self, profiler):
{'fraction_non_alphanumeric': 0.06294042280589365, 'fraction_numerical': 0.0006406149903907751, 'mean_word_length': 3.357990230286113, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6603033', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1650, 'n_words': 534}