class_docstr: A helper class for testing interop with TFX pipelines.
class_docstr_tok: ["A","helper","class","for","testing","interop","with","TFX","pipelines","."]
docstr: Runs a sample TFDV job and stores output.
  
  For the training and evaluation datasets, for each feature, this creates a
  trivial TFDV histogram with three buckets. It writes this output to the
  specified path.
  
  Args:
    tfdv_path: The path to save the TFDV output to.
    train_dataset_name: The name to give the training dataset in the TFDV
      analysis.
    train_features: The names of the features in the training dataset.
    eval_dataset_name: The name to give the evaluation dataset in the TFDV
      analysis.
    eval_features: The names of the features in the evaluation dataset.
    store: The MLMD store to save the TFDV output artifact.
docstr_tok: ["Runs","a","sample","TFDV","job","and","stores","output",".","For","the","training","and","evaluation","datasets",",","for","each","feature",",","this","creates","a","trivial","TFDV","histogram","with","three","buckets",".","It","writes","this","output","to","the","specified","path",".","Args",":","tfdv_path",":","The","path","to","save","the","TFDV","output","to",".","train_dataset_name",":","The","name","to","give","the","training","dataset","in","the","TFDV","analysis",".","train_features",":","The","names","of","the","features","in","the","training","dataset",".","eval_dataset_name",":","The","name","to","give","the","evaluation","dataset","in","the","TFDV","analysis",".","eval_features",":","The","names","of","the","features","in","the","evaluation","dataset",".","store",":","The","MLMD","store","to","save","the","TFDV","output","artifact","."]
code: def _write_tfdv(
      self,
      tfdv_path: str,
      train_dataset_name: str,
      train_features: List[str],
      eval_dataset_name: str,
      eval_features: List[str],
      store: Optional[mlmd.MetadataStore] = None,
  ) -> None:
      """Runs a sample TFDV job and stores output.
  
      For the training and evaluation datasets, for each feature, this creates a
      trivial TFDV histogram with three buckets. It writes this output to the
      specified path.
  
      Args:
        tfdv_path: The path to save the TFDV output to.
        train_dataset_name: The name to give the training dataset in the TFDV
          analysis.
        train_features: The names of the features in the training dataset.
        eval_dataset_name: The name to give the evaluation dataset in the TFDV
          analysis.
        eval_features: The names of the features in the evaluation dataset.
        store: The MLMD store to save the TFDV output artifact.
      """
  
      def _write(
          dataset_name: str, features: List[str], split_name: str
      ):
          stats = statistics_pb2.DatasetFeatureStatistics()
          stats.name = dataset_name
          for feature in features:
              stat_feature = stats.features.add()
              stat_feature.name = feature
              stat_feature.string_stats.rank_histogram.buckets.extend(
                  [
                      statistics_pb2.RankHistogram.Bucket(
                          low_rank=0,
                          high_rank=0,
                          label="a",
                          sample_count=4.0,
                      ),
                      statistics_pb2.RankHistogram.Bucket(
                          low_rank=1,
                          high_rank=1,
                          label="b",
                          sample_count=3.0,
                      ),
                      statistics_pb2.RankHistogram.Bucket(
                          low_rank=2,
                          high_rank=2,
                          label="c",
                          sample_count=2.0,
                      ),
                  ]
              )
          stats_list = statistics_pb2.DatasetFeatureStatisticsList(
              datasets=[stats]
          )
          stats_file = os.path.join(
              tfdv_path, split_name, "FeatureStats.pb"
          )
          io_utils.write_proto_file(stats_file, stats_list)
  
      _write(train_dataset_name, train_features, "Split-train")
      _write(eval_dataset_name, eval_features, "Split-eval")
  
      if store:
          self._put_artifact(store, _TFX_STATS_TYPE, tfdv_path)
  
file_path: model-card-toolkit/model_card_toolkit/utils/testdata/tfxtest.py
imports: import os
  from typing import Any, Callable, List, Optional
  import apache_beam
  import ml_metadata
  import tensorflow_model_analysis
  from absl import flags
  from ml_metadata.proto import metadata_store_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
  from tensorflow_model_analysis.eval_saved_model.example_trainers import fixed_prediction_estimator
  from tfx_bsl.tfxio import raw_tf_record
  from model_card_toolkit.utils import io_utils
  from model_card_toolkit.utils.tf_utils import _TFX_METRICS_TYPE, _TFX_STATS_TYPE
label_desc: Use image node_id 5 for calling the TfxTest obj's underlying member method code with example usage: obj._write_tfdv(tfdv_path, train_dataset_name, train_features, eval_dataset_name, eval_features, store) without return types