# import required libs
import glob
import os

import tensorflow as tf
import tensorflow_model_analysis as tfma
print('TF version: {}'.format(tf.version.VERSION))
print('TFMA version: {}'.format(tfma.version.VERSION_STRING))# Read artifact information from metadata store.
import beam_dag_runner

from tfx.orchestration import metadata
from tfx.types import standard_artifacts

metadata_connection_config = metadata.sqlite_metadata_connection_config(
              beam_dag_runner.METADATA_PATH)
with metadata.Metadata(metadata_connection_config) as store:
    model_eval_artifacts = store.get_artifacts_by_type(standard_artifacts.ModelEvaluation.TYPE_NAME)# configure output paths
# Exact paths to output artifacts can be found in the execution logs
# or KFP Web UI if you are using kubeflow.
model_eval_path = model_eval_artifacts[-1].uri
print("Generated model evaluation result:{}".format(model_eval_path))eval_result = tfma.load_eval_result(model_eval_path)
tfma.view.render_slicing_metrics(eval_result, slicing_spec = tfma.slicer.SingleSliceSpec(columns=['trip_start_hour']))