自定义Python函数式TFX组件如何导出mlpipeline-metrics供KubeFlow UI展示?
注意:本内容为此前提交至TensorFlow TFX官方代码仓库的问题转载,发布至此希望获得更多有效解法,任一渠道拿到可落地的解决方案后,我都会同步更新所有渠道的相关内容。
问题描述
我希望从自定义Python函数式TFX组件中导出mlpipeline-metrics文件,让指标能按照KubeFlow Pipelines官方文档定义的规则,在KubeFlow前端界面正常展示。
以下是用于复现该问题的最小可运行代码:
import json from tfx.dsl.component.experimental.annotations import OutputArtifact from tfx.dsl.component.experimental.decorators import component from tfx.types.standard_artifacts import Artifact class Metric(Artifact): TYPE_NAME = 'Metric' @component def ShowMetric(MLPipeline_Metrics: OutputArtifact[Metric]): rmse_eval = 333.33 metrics = { 'metrics': [ { 'name': 'RMSE-validation', 'numberValue': rmse_eval, 'format': 'RAW' } ] } path = '/tmp/mlpipeline-metrics.json' with open(path, 'w') as _file: json.dump(metrics, _file) MLPipeline_Metrics.uri = path
按照上述代码运行流水线后,KubeFlow前端的「运行输出」标签页会提示「未找到本次运行的指标」,但核对ML Metadata可以确认,对应的输出Artifact已经正常生成。想知道实现该需求的正确操作方法是什么。

内容的提问来源于stack exchange,提问作者Axel Tidemann
相关产品推荐
相关产品推荐

