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 have a local Python environment, you can run the following command:
pip install mlflow
mlflow server --backend-store-uri sqlite:///mlruns.db --port 5000
If you don't have Python environment locally, MLflow also supports Docker deployment or managed services. See Self-Hosting Guide for getting started.
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.