这是 MLflow Typescript SDK 的核心包。它是一个轻量级包,包含核心跟踪功能和手动插桩。
| 软件包 | NPM | 描述 |
|---|---|---|
| mlflow-tracing | 核心跟踪功能和手动插桩。 |
npm install mlflow-tracing
启动 MLflow Tracking Server。如果您有本地 Python 环境,可以运行以下命令:
pip install mlflow
mlflow server --backend-store-uri sqlite:///mlruns.db --port 5000
如果您本地没有 Python 环境,MLflow 也支持 Docker 部署或托管服务。请参阅 自行托管指南 了解入门方法。
在您的应用程序中实例化 MLflow SDK
import * as mlflow from 'mlflow-tracing';
mlflow.init({
trackingUri: 'https://:5000',
experimentId: '<experiment-id>'
});
创建 trace
// Wrap a function with mlflow.trace to generate a span when the function is called.
// MLflow will automatically record the function name, arguments, return value,
// latency, and exception information to the span.
const getWeather = mlflow.trace(
(city: string) => {
return `The weather in ${city} is sunny`;
},
// Pass options to set span name. See https://mlflow.org.cn/docs/latest/genai/tracing/quickstart
// for the full list of options.
{ name: 'get-weather' }
);
getWeather('San Francisco');
// Alternatively, start and end span manually
const span = mlflow.startSpan({ name: 'my-span' });
span.end();
MLflow Typescript SDK 的官方文档可以在 此处 找到。
本项目根据 Apache License 2.0 获得许可。