@arizeai/phoenix-client
Version:
A client for the Phoenix API
102 lines • 3.58 kB
TypeScript
import { type DiagLogLevel } from "@arizeai/phoenix-otel";
import { ClientFn } from "../types/core.js";
import type { ExperimentEvaluatorLike, ExperimentTask } from "../types/experiments.js";
import { type Logger } from "../types/logger.js";
export type ResumeExperimentParams = ClientFn & {
/**
* The ID of the experiment to resume
*/
readonly experimentId: string;
/**
* The task to run on incomplete examples
*/
readonly task: ExperimentTask;
/**
* Optional evaluators to run on completed task runs
* @default undefined
*/
readonly evaluators?: readonly ExperimentEvaluatorLike[];
/**
* The logger to use
* @default console
*/
readonly logger?: Logger;
/**
* The number of concurrent task executions
* @default 5
*/
readonly concurrency?: number;
/**
* Whether to set the global tracer provider when running the task.
* @default true
*/
readonly setGlobalTracerProvider?: boolean;
/**
* Whether to use batch span processor for tracing.
* @default true
*/
readonly useBatchSpanProcessor?: boolean;
/**
* Log level to set for the default DiagConsoleLogger when tracing.
*/
readonly diagLogLevel?: DiagLogLevel;
/**
* Stop processing and exit as soon as any task fails.
* @default false
*/
readonly stopOnFirstError?: boolean;
};
/**
* Resume an incomplete experiment by running only the missing or failed runs.
*
* This function identifies which (example, repetition) pairs have not been completed
* (either missing or failed) and re-runs the task only for those pairs. Optionally,
* evaluators can be run on the completed runs after task execution.
*
* The function processes incomplete runs in batches using pagination to minimize memory usage.
*
* @throws {Error} Throws different error types based on failure:
* - "TaskFetchError": Unable to fetch incomplete runs from the server.
* Always thrown regardless of stopOnFirstError, as it indicates critical infrastructure failure.
* - "TaskAbortedError": stopOnFirstError=true and a task failed.
* Original error preserved in `cause` property.
* - Generic Error: Other task execution errors or unexpected failures.
*
* @example
* ```ts
* import { resumeExperiment } from "@arizeai/phoenix-client/experiments";
*
* // Resume an interrupted experiment
* try {
* await resumeExperiment({
* experimentId: "exp_123",
* task: myTask,
* });
* } catch (error) {
* // Handle by error name (no instanceof needed)
* if (error.name === "TaskFetchError") {
* console.error("Failed to connect to server:", error.cause);
* } else if (error.name === "TaskAbortedError") {
* console.error("Task stopped due to error:", error.cause);
* } else {
* console.error("Unexpected error:", error);
* }
* }
*
* // Resume with evaluators
* await resumeExperiment({
* experimentId: "exp_123",
* task: myTask,
* evaluators: [correctnessEvaluator, relevanceEvaluator],
* });
*
* // Stop on first error (useful for debugging)
* await resumeExperiment({
* experimentId: "exp_123",
* task: myTask,
* stopOnFirstError: true, // Exit immediately on first task failure
* });
* ```
*/
export declare function resumeExperiment({ client: _client, experimentId, task, evaluators, logger, concurrency, setGlobalTracerProvider, useBatchSpanProcessor, diagLogLevel, stopOnFirstError, }: ResumeExperimentParams): Promise<void>;
//# sourceMappingURL=resumeExperiment.d.ts.map