class_docstr: TensorFlow ExampleValidator component executor.
class_docstr_tok: ["TensorFlow","ExampleValidator","component","executor","."]
docstr: TensorFlow ExampleValidator executor entrypoint.
  
  This validates statistics against the schema.
  
  Args:
    input_dict: Input dict from input key to a list of artifacts, including:
      - statistics: A list of type `standard_artifacts.ExampleStatistics`
        generated by StatisticsGen.
      - schema: A list of type `standard_artifacts.Schema` which should
        contain a single schema artifact.
    output_dict: Output dict from key to a list of artifacts, including:
      - output: A list of 'standard_artifacts.ExampleAnomalies' of size one.
        It will include a single binary proto file which contains all
        anomalies found.
    exec_properties: A dict of execution properties.
      - exclude_splits: JSON-serialized list of names of splits that the
        example validator should not validate.
      - custom_validation_config: An optional configuration for specifying
        custom validations with SQL.
  
  Returns:
    ExecutionResult proto with anomalies and the component generated alerts
    execution property set with anomalies alerts, if any.
docstr_tok: ["TensorFlow","ExampleValidator","executor","entrypoint",".","This","validates","statistics","against","the","schema",".","Args",":","input_dict",":","Input","dict","from","input","key","to","a","list","of","artifacts",",","including",":","-","statistics",":","A","list","of","type","`","standard_artifacts.ExampleStatistics","`","generated","by","StatisticsGen",".","-","schema",":","A","list","of","type","`","standard_artifacts.Schema","`","which","should","contain","a","single","schema","artifact",".","output_dict",":","Output","dict","from","key","to","a","list","of","artifacts",",","including",":","-","output",":","A","list","of","'standard_artifacts.ExampleAnomalies","'","of","size","one",".","It","will","include","a","single","binary","proto","file","which","contains","all","anomalies","found",".","exec_properties",":","A","dict","of","execution","properties",".","-","exclude_splits",":","JSON-serialized","list","of","names","of","splits","that","the","example","validator","should","not","validate",".","-","custom_validation_config",":","An","optional","configuration","for","specifying","custom","validations","with","SQL",".","Returns",":","ExecutionResult","proto","with","anomalies","and","the","component","generated","alerts","execution","property","set","with","anomalies","alerts",",","if","any","."]
code: def Do(
      self,
      input_dict: Dict[str, List[types.Artifact]],
      output_dict: Dict[str, List[types.Artifact]],
      exec_properties: Dict[str, Any],
  ) -> execution_result_pb2.ExecutorOutput:
      """TensorFlow ExampleValidator executor entrypoint.
  
      This validates statistics against the schema.
  
      Args:
        input_dict: Input dict from input key to a list of artifacts, including:
          - statistics: A list of type `standard_artifacts.ExampleStatistics`
            generated by StatisticsGen.
          - schema: A list of type `standard_artifacts.Schema` which should
            contain a single schema artifact.
        output_dict: Output dict from key to a list of artifacts, including:
          - output: A list of 'standard_artifacts.ExampleAnomalies' of size one.
            It will include a single binary proto file which contains all
            anomalies found.
        exec_properties: A dict of execution properties.
          - exclude_splits: JSON-serialized list of names of splits that the
            example validator should not validate.
          - custom_validation_config: An optional configuration for specifying
            custom validations with SQL.
  
      Returns:
        ExecutionResult proto with anomalies and the component generated alerts
        execution property set with anomalies alerts, if any.
      """
      self._log_startup(input_dict, output_dict, exec_properties)
  
      # Load and deserialize exclude splits from execution properties.
      exclude_splits = (
          json_utils.loads(
              exec_properties.get(
                  standard_component_specs.EXCLUDE_SPLITS_KEY, "null"
              )
          )
          or []
      )
      if not isinstance(exclude_splits, list):
          raise ValueError(
              "exclude_splits in execution properties needs to be a "
              "list. Got %s instead." % type(exclude_splits)
          )
      # Setup output splits.
      stats_artifact = artifact_utils.get_single_instance(
          input_dict[standard_component_specs.STATISTICS_KEY]
      )
      stats_split_names = artifact_utils.decode_split_names(
          stats_artifact.split_names
      )
      split_names = [
          split
          for split in stats_split_names
          if split not in exclude_splits
      ]
      anomalies_artifact = artifact_utils.get_single_instance(
          output_dict[standard_component_specs.ANOMALIES_KEY]
      )
      anomalies_artifact.split_names = (
          artifact_utils.encode_split_names(split_names)
      )
  
      schema = io_utils.SchemaReader().read(
          io_utils.get_only_uri_in_dir(
              artifact_utils.get_single_uri(
                  input_dict[standard_component_specs.SCHEMA_KEY]
              )
          )
      )
  
      alerts = (
          component_generated_alert_pb2.ComponentGeneratedAlertList()
      )
  
      blessed_value_dict = {}
      for split in artifact_utils.decode_split_names(
          stats_artifact.split_names
      ):
          if split in exclude_splits:
              continue
  
          logging.info(
              "Validating schema against the computed statistics for "
              "split %s.",
              split,
          )
          stats = stats_artifact_utils.load_statistics(
              stats_artifact, split
          ).proto()
          label_inputs = {
              standard_component_specs.STATISTICS_KEY: stats,
              standard_component_specs.SCHEMA_KEY: schema,
              standard_component_specs.CUSTOM_VALIDATION_CONFIG_KEY: exec_properties.get(
                  standard_component_specs.CUSTOM_VALIDATION_CONFIG_KEY
              ),
          }
          output_uri = artifact_utils.get_split_uri(
              output_dict[standard_component_specs.ANOMALIES_KEY], split
          )
          label_outputs = {labels.SCHEMA_DIFF_PATH: output_uri}
  
          anomalies = self._Validate(label_inputs, label_outputs)
          if anomalies.anomaly_info or anomalies.HasField(
              "dataset_anomaly_info"
          ):
              blessed_value_dict[split] = NOT_BLESSED_VALUE
          else:
              blessed_value_dict[split] = BLESSED_VALUE
  
          alerts.component_generated_alert_list.extend(
              _create_anomalies_alerts(anomalies, split)
          )
          logging.info("Anomalies alerts created for split %s.", split)
  
          logging.info(
              "Validation complete for split %s. Anomalies written to "
              "%s.",
              split,
              output_uri,
          )
  
          # Set blessed custom property for anomalies artifact.
          anomalies_artifact.set_json_value_custom_property(
              ARTIFACT_PROPERTY_BLESSED_KEY, blessed_value_dict
          )
  
      executor_output = execution_result_pb2.ExecutorOutput()
      executor_output.output_artifacts[
          standard_component_specs.ANOMALIES_KEY
      ].artifacts.append(anomalies_artifact.mlmd_artifact)
  
      # Set component generated alerts execution property in ExecutorOutput if
      # any anomalies alerts exist.
      if alerts.component_generated_alert_list:
          any_proto = any_pb2.Any()
          any_proto.Pack(alerts)
          executor_output.execution_properties[
              constants.COMPONENT_GENERATED_ALERTS_KEY
          ].proto_value.CopyFrom(any_proto)
  
      return executor_output
  
imports: import os
  from typing import Any, Dict, List
  from absl import logging
  import tensorflow_data_validation
  from tfx import types
  from tfx.components.example_validator import labels
  from tfx.components.statistics_gen import stats_artifact_utils
  from tfx.components.util import value_utils
  from tfx.dsl.components.base import base_executor
  from tfx.orchestration.experimental.core import component_generated_alert_pb2
  from tfx.orchestration.experimental.core import constants
  from tfx.proto.orchestration import execution_result_pb2
  from tfx.types import artifact_utils
  from tfx.types import standard_component_specs
  from tfx.utils import io_utils
  from tfx.utils import json_utils
  from tfx.utils import writer_utils
  from google.protobuf import any_pb2
  from tensorflow_metadata.proto.v0 import anomalies_pb2
label_desc: Use image node_id 1 for calling the Executor obj's underlying member method code with example usage: obj.Do(input_dict, output_dict, exec_properties) and returns: executor_output