This is the core package of the MLflow Typescript SDK. It is a skinny package that includes the core tracing functionality and manual instrumentation.
Package | NPM | Description |
---|---|---|
mlflow-tracing | The core tracing functionality and manual instrumentation. |
npm install mlflow-tracing
Start MLflow Tracking Server if you don't have one already:
pip install mlflow
mlflow server --backend-store-uri sqlite:///mlruns.db --port 5000
Self-hosting MLflow server requires Python 3.10 or higher. If you don't have one, you can also use managed MLflow service for free to get started quickly.
Instantiate MLflow SDK in your application:
import * as mlflow from 'mlflow-tracing';
mlflow.init({
trackingUri: 'http://localhost:5000',
experimentId: '<experiment-id>'
});
Create a 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/docs/latest/genai/tracing/app-instrumentation/typescript-sdk
// 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();
Official documentation for MLflow Typescript SDK can be found here.
This project is licensed under the Apache License 2.0.