code: def test_scaffold_assets_with_source(
      self, output_file_format: str, artifacts: bool
  ):
      train_dataset_name = "Dataset-Split-train"
      train_features = ["feature_name1"]
      eval_dataset_name = "Dataset-Split-eval"
      eval_features = ["feature_name2", "feature_name3"]
  
      test_dir = self.create_tempdir()
      tfma_path = os.path.join(test_dir, "tfma")
      tfdv_path = os.path.join(test_dir, "tfdv")
      pushed_model_path = os.path.join(test_dir, "pushed_model")
  
      add_metrics_callbacks = [
          tfma.post_export_metrics.example_count(),
          tfma.post_export_metrics.calibration_plot_and_prediction_histogram(
              num_buckets=2
          ),
      ]
  
      if artifacts:
          mlmd_store = self._set_up_mlmd()
          self._write_tfma(
              tfma_path,
              output_file_format,
              add_metrics_callbacks,
              mlmd_store,
          )
          self._write_tfdv(
              tfdv_path,
              train_dataset_name,
              train_features,
              eval_dataset_name,
              eval_features,
              mlmd_store,
          )
          model_evaluation_artifacts = mlmd_store.get_artifacts_by_type(
              _TFX_METRICS_TYPE
          )
          example_statistics_artifacts = (
              mlmd_store.get_artifacts_by_type(_TFX_STATS_TYPE)
          )
          # Use placeholder artifact to avoid introducing tfx as a dependency
          pushed_model_artifact = metadata_store_pb2.Artifact(
              uri=pushed_model_path
          )
          tfma_src = tf_sources.TfmaSource(
              model_evaluation_artifacts=model_evaluation_artifacts,
              metrics_exclude=["average_loss"],
          )
          tfdv_src = tf_sources.TfdvSource(
              example_statistics_artifacts=example_statistics_artifacts,
              features_include=["feature_name1", "feature_name3"],
          )
          model_src = tf_sources.ModelSource(
              pushed_model_artifact=pushed_model_artifact
          )
      else:
          self._write_tfma(
              tfma_path, output_file_format, add_metrics_callbacks
          )
          self._write_tfdv(
              tfdv_path,
              train_dataset_name,
              train_features,
              eval_dataset_name,
              eval_features,
          )
          tfma_src = tf_sources.TfmaSource(
              eval_result_paths=[tfma_path],
              metrics_exclude=["average_loss"],
          )
          tfdv_src = tf_sources.TfdvSource(
              dataset_statistics_paths=[tfdv_path],
              features_include=["feature_name1", "feature_name3"],
          )
          model_src = tf_sources.ModelSource(
              pushed_model_path=pushed_model_path
          )
  
      mc = core.ModelCardToolkit(
          source=tf_sources.Source(
              tfma=tfma_src, tfdv=tfdv_src, model=model_src
          )
      ).scaffold_assets()  # yapf: disable
  
      with self.subTest(name="quantitative_analysis"):
          list_to_proto = lambda lst: [x.to_proto() for x in lst]
          expected_performance_metrics = [
              model_card.PerformanceMetric(
                  type="post_export_metrics/example_count", value="2.0"
              )
          ]
          self.assertCountEqual(
              list_to_proto(
                  mc.quantitative_analysis.performance_metrics
              ),
              list_to_proto(expected_performance_metrics),
          )
          self.assertLen(
              mc.quantitative_analysis.graphics.collection, 1
          )
  
      with self.subTest(name="model_parameters.data"):
          self.assertLen(mc.model_parameters.data, 2)  # train and eval
          for dataset in mc.model_parameters.data:
              for graphic in dataset.graphics.collection:
                  self.assertIsNotNone(
                      graphic.image,
                      msg=f"No image found for graphic: {dataset.name} {graphic.name}",
                  )
                  graphic.image = (
                      None  # ignore graphic.image for below assertions
                  )
          self.assertIn(
              model_card.Dataset(
                  name=train_dataset_name,
                  graphics=model_card.GraphicsCollection(
                      collection=[
                          model_card.Graphic(
                              name="counts | feature_name1"
                          )
                      ]
                  ),
              ),
              mc.model_parameters.data,
          )
          self.assertIn(
              model_card.Dataset(
                  name=eval_dataset_name,
                  graphics=model_card.GraphicsCollection(
                      collection=[
                          model_card.Graphic(
                              name="counts | feature_name3"
                          )
                      ]
                  ),
              ),
              mc.model_parameters.data,
          )
          self.assertNotIn(
              model_card.Dataset(
                  name=eval_dataset_name,
                  graphics=model_card.GraphicsCollection(
                      collection=[
                          model_card.Graphic(
                              name="counts | feature_name2"
                          )
                      ]
                  ),
              ),
              mc.model_parameters.data,
          )
  
      with self.subTest(name="model_details.path"):
          self.assertEqual(mc.model_details.path, pushed_model_path)
  
file_path: model-card-toolkit/model_card_toolkit/core_tf_test.py
imports: import os
  from unittest import mock
  from absl import flags
  from absl.testing import absltest, parameterized
  from model_card_toolkit import core, dependencies, model_card
label_desc: Use image node_id 6 for calling the TfCoreTest obj's underlying member method code with example usage: obj.test_scaffold_assets_with_source(output_file_format, artifacts) without return types