great_expectations/expectations/expectation.py
def run_diagnostics(self, pretty_print=True):
        """
        Produce a diagnostic report about this expectation.
        The current uses for this method's output are
        using the JSON structure to populate the Public Expectation Gallery
        and enabling a fast devloop for developing new expectations where the
        contributors can quickly check the completeness of their expectations.

        The content of the report:
        * name and description
        * "library metadata", such as the GitHub usernames of the expectation's authors
        * the execution engines the expectation is implemented for
        * the implemented renderers
        * tests in "examples" member variable
        * the tests are executed against the execution engines for which the expectation
        is implemented and the output of the test runs is included in the report.

        At least one test case with include_in_gallery=True must be present in the examples to
        produce the metrics, renderers and execution engines parts of the report. This is due to
        a get_validation_dependencies requiring expectation_config as an argument.

        If errors are encountered in the process of running the diagnostics, they are assumed to be due to
        incompleteness of the Expectation's implementation (e.g., declaring a dependency on Metrics
        that do not exist). These errors are added under "errors" key in the report.

        :param pretty_print: TODO: this argument is not currently used. The intent is to return
        a well formatted and easily readable text instead of the dictionary when the argument is set
        to True
        :return: a dictionary view of the report
        """

        camel_name = self.__class__.__name__
        snake_name = camel_to_snake(self.__class__.__name__)
        docstring, short_description = self._get_docstring_and_short_description()
        library_metadata = self._get_library_metadata()

        report_obj = {
            "description": {
                "camel_name": camel_name,
                "snake_name": snake_name,
                "short_description": short_description,
                "docstring": docstring,
            },
            "library_metadata": library_metadata,
            "renderers": {},
            "examples": [],
            "metrics": [],
            "execution_engines": {},
            "test_report": [],
            "diagnostics_report": [],
        }

        # Generate artifacts from an example case
        gallery_examples = self._get_examples()
        report_obj.update({"examples": gallery_examples})

        if gallery_examples != []:
            example_data, example_test = self._choose_example(gallery_examples)

            # TODO: this should be creating a Batch using an engine
            test_batch = Batch(data=pd.DataFrame(example_data))

            expectation_config = ExpectationConfiguration(
                **{"expectation_type": snake_name, "kwargs": example_test}
            )

            validation_result = None
            try:
                validation_results = self._instantiate_example_validation_results(
                    test_batch=test_batch,
                    expectation_config=expectation_config,
                )
                validation_result = validation_results[0]
            except (
                GreatExpectationsError,
                AttributeError,
                ImportError,
                LookupError,
                ValueError,
                SyntaxError,
            ) as e:
                report_obj = self._add_error_to_diagnostics_report(
                    report_obj, e, traceback.format_exc()
                )

            if validation_result is not None:
                renderers = self._get_renderer_dict(
                    expectation_name=snake_name,
                    expectation_config=expectation_config,
                    validation_result=validation_result,
                )
                report_obj.update({"renderers": renderers})

            upstream_metrics = None
            try:
                upstream_metrics = self._get_upstream_metrics(expectation_config)
                report_obj.update({"metrics": upstream_metrics})
            except GreatExpectationsError as e:
                report_obj = self._add_error_to_diagnostics_report(
                    report_obj, e, traceback.format_exc()
                )

            introspected_execution_engines = None
            if upstream_metrics is not None:
                introspected_execution_engines = self._get_execution_engine_dict(
                    upstream_metrics=upstream_metrics,
                )
                report_obj.update({"execution_engines": introspected_execution_engines})

            try:
                tests = self._get_examples(return_only_gallery_examples=False)
                if len(tests) > 0:
                    if introspected_execution_engines is not None:
                        test_results = self._get_test_results(
                            snake_name,
                            tests,
                            introspected_execution_engines,
                        )
                        report_obj.update({"test_report": test_results})
            except Exception as e:
                report_obj = self._add_error_to_diagnostics_report(
                    report_obj, e, traceback.format_exc()
                )

        return report_obj

        Produce a diagnostic report about this expectation.
        The current uses for this method's output are
        using the JSON structure to populate the Public Expectation Gallery
        and enabling a fast devloop for developing new expectations where the
        contributors can quickly check the completeness of their expectations.

        The content of the report:
        * name and description
        * "library metadata", such as the GitHub usernames of the expectation's authors
        * the execution engines the expectation is implemented for
        * the implemented renderers
        * tests in "examples" member variable
        * the tests are executed against the execution engines for which the expectation
        is implemented and the output of the test runs is included in the report.

        At least one test case with include_in_gallery=True must be present in the examples to
        produce the metrics, renderers and execution engines parts of the report. This is due to
        a get_validation_dependencies requiring expectation_config as an argument.

        If errors are encountered in the process of running the diagnostics, they are assumed to be due to
        incompleteness of the Expectation's implementation (e.g., declaring a dependency on Metrics
        that do not exist). These errors are added under "errors" key in the report.

        :param pretty_print: TODO: this argument is not currently used. The intent is to return
        a well formatted and easily readable text instead of the dictionary when the argument is set
        to True
        :return: a dictionary view of the report
        
Produce a diagnostic report about this expectation.
The current uses for this method's output are
using the JSON structure to populate the Public Expectation Gallery
and enabling a fast devloop for developing new expectations where the
contributors can quickly check the completeness of their expectations.

The content of the report:
name and description
"library metadata", such as the GitHub usernames of the expectation's authors
the execution engines the expectation is implemented for
the implemented renderers
tests in "examples" member variable
the tests are executed against the execution engines for which the expectation
is implemented and the output of the test runs is included in the report.

At least one test case with include_in_gallery=True must be present in the examples to
produce the metrics, renderers and execution engines parts of the report. This is due to
a get_validation_dependencies requiring expectation_config as an argument.

If errors are encountered in the process of running the diagnostics, they are assumed to be due to
incompleteness of the Expectation's implementation . These errors are added under "errors" key in the report.
Produce a diagnostic report about this expectation . The current uses for this method ' s output are using the JSON structure to populate the Public Expectation Gallery and enabling a fast devloop for developing new expectations where the contributors can quickly check the completeness of their expectations . The content of the report : name and description " library metadata " such as the GitHub usernames of the expectation ' s authors the execution engines the expectation is implemented for the implemented renderers tests in " examples " member variable the tests are executed against the execution engines for which the expectation is implemented and the output of the test runs is included in the report . At least one test case with include_in_gallery = True must be present in the examples to produce the metrics renderers and execution engines parts of the report . This is due to a get_validation_dependencies requiring expectation_config as an argument . If errors are encountered in the process of running the diagnostics they are assumed to be due to incompleteness of the Expectation ' s implementation . These errors are added under " errors " key in the report .
def run_diagnostics(self, pretty_print=True):
        camel_name = self.__class__.__name__
        snake_name = camel_to_snake(self.__class__.__name__)
        docstring, short_description = self._get_docstring_and_short_description()
        library_metadata = self._get_library_metadata()
        report_obj = {
            "description": {
                "camel_name": camel_name,
                "snake_name": snake_name,
                "short_description": short_description,
                "docstring": docstring,
            },
            "library_metadata": library_metadata,
            "renderers": {},
            "examples": [],
            "metrics": [],
            "execution_engines": {},
            "test_report": [],
            "diagnostics_report": [],
        }
        gallery_examples = self._get_examples()
        report_obj.update({"examples": gallery_examples})
        if gallery_examples != []:
            example_data, example_test = self._choose_example(gallery_examples)
            test_batch = Batch(data=pd.DataFrame(example_data))
            expectation_config = ExpectationConfiguration(
                **{"expectation_type": snake_name, "kwargs": example_test}
            )
            validation_result = None
            try:
                validation_results = self._instantiate_example_validation_results(
                    test_batch=test_batch,
                    expectation_config=expectation_config,
                )
                validation_result = validation_results[0]
            except (
                GreatExpectationsError,
                AttributeError,
                ImportError,
                LookupError,
                ValueError,
                SyntaxError,
            ) as e:
                report_obj = self._add_error_to_diagnostics_report(
                    report_obj, e, traceback.format_exc()
                )
            if validation_result is not None:
                renderers = self._get_renderer_dict(
                    expectation_name=snake_name,
                    expectation_config=expectation_config,
                    validation_result=validation_result,
                )
                report_obj.update({"renderers": renderers})
            upstream_metrics = None
            try:
                upstream_metrics = self._get_upstream_metrics(expectation_config)
                report_obj.update({"metrics": upstream_metrics})
            except GreatExpectationsError as e:
                report_obj = self._add_error_to_diagnostics_report(
                    report_obj, e, traceback.format_exc()
                )
            introspected_execution_engines = None
            if upstream_metrics is not None:
                introspected_execution_engines = self._get_execution_engine_dict(
                    upstream_metrics=upstream_metrics,
                )
                report_obj.update({"execution_engines": introspected_execution_engines})
            try:
                tests = self._get_examples(return_only_gallery_examples=False)
                if len(tests) > 0:
                    if introspected_execution_engines is not None:
                        test_results = self._get_test_results(
                            snake_name,
                            tests,
                            introspected_execution_engines,
                        )
                        report_obj.update({"test_report": test_results})
            except Exception as e:
                report_obj = self._add_error_to_diagnostics_report(
                    report_obj, e, traceback.format_exc()
                )
        return report_obj
def run_diagnostics ( self , pretty_print = True ) : camel_name = self . __class__ . __name__ snake_name = camel_to_snake ( self . __class__ . __name__ ) docstring , short_description = self . _get_docstring_and_short_description ( ) library_metadata = self . _get_library_metadata ( ) report_obj = { "description" : { "camel_name" : camel_name , "snake_name" : snake_name , "short_description" : short_description , "docstring" : docstring , } , "library_metadata" : library_metadata , "renderers" : { } , "examples" : [ ] , "metrics" : [ ] , "execution_engines" : { } , "test_report" : [ ] , "diagnostics_report" : [ ] , } gallery_examples = self . _get_examples ( ) report_obj . update ( { "examples" : gallery_examples } ) if gallery_examples != [ ] : example_data , example_test = self . _choose_example ( gallery_examples ) test_batch = Batch ( data = pd . DataFrame ( example_data ) ) expectation_config = ExpectationConfiguration ( ** { "expectation_type" : snake_name , "kwargs" : example_test } ) validation_result = None try : validation_results = self . _instantiate_example_validation_results ( test_batch = test_batch , expectation_config = expectation_config , ) validation_result = validation_results [ 0 ] except ( GreatExpectationsError , AttributeError , ImportError , LookupError , ValueError , SyntaxError , ) as e : report_obj = self . _add_error_to_diagnostics_report ( report_obj , e , traceback . format_exc ( ) ) if validation_result is not None : renderers = self . _get_renderer_dict ( expectation_name = snake_name , expectation_config = expectation_config , validation_result = validation_result , ) report_obj . update ( { "renderers" : renderers } ) upstream_metrics = None try : upstream_metrics = self . _get_upstream_metrics ( expectation_config ) report_obj . update ( { "metrics" : upstream_metrics } ) except GreatExpectationsError as e : report_obj = self . _add_error_to_diagnostics_report ( report_obj , e , traceback . format_exc ( ) ) introspected_execution_engines = None if upstream_metrics is not None : introspected_execution_engines = self . _get_execution_engine_dict ( upstream_metrics = upstream_metrics , ) report_obj . update ( { "execution_engines" : introspected_execution_engines } ) try : tests = self . _get_examples ( return_only_gallery_examples = False ) if len ( tests ) > 0 : if introspected_execution_engines is not None : test_results = self . _get_test_results ( snake_name , tests , introspected_execution_engines , ) report_obj . update ( { "test_report" : test_results } ) except Exception as e : report_obj = self . _add_error_to_diagnostics_report ( report_obj , e , traceback . format_exc ( ) ) return report_obj
Produce a diagnostic report about this expectation.
Produce a diagnostic report about this expectation .
"""
        Produce a diagnostic report about this expectation.
        The current uses for this method's output are
        using the JSON structure to populate the Public Expectation Gallery
        and enabling a fast devloop for developing new expectations where the
        contributors can quickly check the completeness of their expectations.

        The content of the report:
        * name and description
        * "library metadata", such as the GitHub usernames of the expectation's authors
        * the execution engines the expectation is implemented for
        * the implemented renderers
        * tests in "examples" member variable
        * the tests are executed against the execution engines for which the expectation
        is implemented and the output of the test runs is included in the report.

        At least one test case with include_in_gallery=True must be present in the examples to
        produce the metrics, renderers and execution engines parts of the report. This is due to
        a get_validation_dependencies requiring expectation_config as an argument.

        If errors are encountered in the process of running the diagnostics, they are assumed to be due to
        incompleteness of the Expectation's implementation (e.g., declaring a dependency on Metrics
        that do not exist). These errors are added under "errors" key in the report.

        :param pretty_print: TODO: this argument is not currently used. The intent is to return
        a well formatted and easily readable text instead of the dictionary when the argument is set
        to True
        :return: a dictionary view of the report
        """ # Generate artifacts from an example case # TODO: this should be creating a Batch using an engine
a dictionary view of the report
a dictionary view of the report
self
pretty_print
this argument is not currently used. The intent is to return
a well formatted and easily readable text instead of the dictionary when the argument is set
to True
this argument is not currently used . The intent is to return a well formatted and easily readable text instead of the dictionary when the argument is set to True