You need to enable JavaScript to run this app. 自定义Python函数式TFX组件如何导出mlpipeline-metrics供KubeFlow UI展示?
优惠活动
大模型
产品
解决方案
定价
更多

自定义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已经正常生成。想知道实现该需求的正确操作方法是什么。

KubeFlow UI界面截图


内容的提问来源于stack exchange,提问作者Axel Tidemann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.06 15:06:00