import { AuthProvider } from '../auth'; /** * User-facing shape for specifying a Databricks Unity Catalog trace location. * * All three fields are required. Unlike Python's * `mlflow.set_experiment(trace_location=UnityCatalog(...))`, the TS SDK does * not upsert the underlying UC trace location, so it can't default * `tablePrefix` to anything sensible - the customer must point at a * trace location that is already provisioned in the workspace. */ export interface UnityCatalogLocationOptions { catalogName: string; schemaName: string; tablePrefix: string; } /** * Configuration options for the MLflow tracing SDK */ export interface MLflowTracingConfig { /** * The host where traces will be logged. * Can be: * - HTTP URI for MLflow trace server backend * - "databricks" (uses default profile) * - "databricks://profile" (uses specific profile) */ trackingUri: string; /** * The experiment ID where traces will be logged */ experimentId: string; /** * The location of the Databricks config file, default to ~/.databrickscfg */ databricksConfigPath?: string; /** * The Databricks host. If not provided, the host will be read from the Databricks config file. * @deprecated For Databricks auth, prefer using environment variables or config profiles. * The auth system will automatically resolve credentials. */ host?: string; /** * The Databricks token. If not provided, the token will be read from the Databricks config file. * @deprecated For Databricks auth, prefer using environment variables or config profiles. * The auth system will automatically resolve credentials. */ databricksToken?: string; /** * The tracking server username for basic auth. */ trackingServerUsername?: string; /** * The tracking server password for basic auth. */ trackingServerPassword?: string; /** * Bearer token for OSS MLflow tracking servers. * Can also be set via MLFLOW_TRACKING_TOKEN environment variable. */ trackingServerToken?: string; /** * Workspace name for MLflow servers with workspaces enabled (OSS/non-Databricks only). * Sets the X-MLFLOW-WORKSPACE header on requests to self-hosted MLflow. * Can also be set via MLFLOW_WORKSPACE environment variable (takes precedence). */ workspace?: string; /** * Optional Databricks Unity Catalog trace location. When provided, the SDK * generates V4 trace IDs and persists trace tags / metadata via the V4 * `CreateTraceInfo` endpoint, mirroring Python's * `mlflow.set_experiment(trace_location=UnityCatalog(...))`. When omitted, * traces use the V3 experiment-backed path. * * The UC trace location must already be provisioned in the workspace; the * TS SDK does not upsert it. */ traceLocation?: UnityCatalogLocationOptions; } /** * Initialization options for the MLflow tracing SDK. The trackingUri and experimentId * can be omitted and will be resolved from environment variables when available. Since * this is used on the client side, we need to make sure the trackingUri and experimentId * are required. */ export type MLflowTracingInitOptions = Partial; /** * Configure the MLflow tracing SDK with tracking location settings. * This must be called before using other tracing functions. * * Call once per process. Calling `init()` again will tear down the existing * OpenTelemetry SDK and start a fresh one, but the underlying NodeSDK * shutdown is asynchronous and may race with subsequent tracer registration; * configuration is intended to be set up once at startup, not reconfigured * mid-process. * * ## Authentication * * ### Databricks (trackingUri = "databricks" or "databricks://profile") * * Authentication is handled automatically by the Databricks SDK. It supports: * - Personal Access Tokens (DATABRICKS_TOKEN env var) * - OAuth M2M service principals (DATABRICKS_CLIENT_ID/DATABRICKS_CLIENT_SECRET) * - Azure CLI / Azure MSI / Azure Client Secret * - Google Cloud credentials * - Config file profiles (~/.databrickscfg) * * For Databricks Apps, credentials are automatically injected by the runtime. * * ### OSS MLflow (trackingUri = HTTP URL) * * Authentication is resolved in priority order: * 1. Basic Auth (trackingServerUsername/Password or MLFLOW_TRACKING_USERNAME/PASSWORD) * 2. Bearer Token (trackingServerToken or MLFLOW_TRACKING_TOKEN) * 3. No Auth * * @param config Configuration object with trackingUri and experimentId * * @example * ```typescript * import { init, withSpan } from '@mlflow/core'; * * // Option 1: Use MLflow Tracking Server * init({ * trackingUri: "http://localhost:5000", * experimentId: "123456789" * }); * * // Option 2: Use default Databricks profile from ~/.databrickscfg * init({ * trackingUri: "databricks", * experimentId: "123456789" * }); * * // Option 3: Use specific Databricks profile * init({ * trackingUri: "databricks://my-profile", * experimentId: "123456789" * }); * * // Option 4: Custom config file path * init({ * trackingUri: "databricks", * experimentId: "123456789", * databricksConfigPath: "/path/to/my/databrickscfg" * }); * * // Option 5: Override with explicit host/token (backwards compatibility) * init({ * trackingUri: "databricks", * experimentId: "123456789", * host: "https://my-workspace.databricks.com", * databricksToken: "my-token" * }); * * // Option 6: OSS MLflow with basic auth * init({ * trackingUri: "http://localhost:5000", * experimentId: "123456789", * trackingServerUsername: "user", * trackingServerPassword: "pass" * }); * * // Option 7: OSS MLflow with bearer token * init({ * trackingUri: "http://localhost:5000", * experimentId: "123456789", * trackingServerToken: "my-token" * }); * * // Option 8: Databricks Unity Catalog trace location. * // Mirrors Python's `mlflow.set_experiment(..., trace_location=UnityCatalog(...))`. * // The UC trace location must already be provisioned for this workspace. * init({ * trackingUri: "databricks", * experimentId: "123456789", * traceLocation: { * catalogName: "my_catalog", * schemaName: "my_schema", * tablePrefix: "my_prefix", * }, * }); * * // Now you can use tracing functions * function add(a: number, b: number) { * return withSpan( * { name: 'add', inputs: { a, b } }, * (span) => { * const result = a + b; * span.setOutputs({ result }); * return result; * } * ); * } * ``` */ export declare function init(config: MLflowTracingInitOptions): void; /** * Get the current configuration. Throws an error if not configured. * @returns The current MLflow tracing configuration */ export declare function getConfig(): MLflowTracingConfig; /** * Get the current authentication provider. Throws an error if not configured. * @returns The current authentication provider */ export declare function getAuthProvider(): AuthProvider; /** * Reset the global configuration. For testing purposes only. * @internal */ export declare function resetConfig(): void;