@arizeai/phoenix-client
Version:
A client for the Phoenix API
82 lines • 3.63 kB
TypeScript
import { type GlobalTracerProviderRegistration, type NodeTracerProvider } from "@arizeai/phoenix-otel";
import { type RunState, type SuiteState } from "./state.js";
import type { Annotation, KVMap } from "./types.js";
export declare function isFalsyFlag(value: string | undefined): boolean;
/**
* Reset the process-level tracking latch. Test-only seam so unit tests can
* exercise the enable/disable transitions in isolation; not part of the
* public API.
*
* @internal
*/
export declare function __resetTrackingLatchForTests(): void;
/**
* Decide whether tests should sync to Phoenix.
*
* Tracing is enabled by default. It can be disabled globally by setting
* `PHOENIX_TEST_TRACKING=false`, or per suite via `SuiteConfig.dryRun`.
*
* The global disable is sticky for the lifetime of the process: once the flag
* is seen falsy — at load time or on any later call — tracking stays off for
* every suite. This keeps offline mode deterministic regardless of which
* suites are included in a run, or the order they execute in.
*/
export declare function isTrackingEnabled(suite?: SuiteState): {
enabled: boolean;
reason?: string;
};
/**
* Resolve the repetition count for a test: per-test value, else suite-level,
* else the `PHOENIX_TEST_REPETITIONS` env var, else `1`. Non-positive or
* non-finite values fall back to `1`.
*/
export declare function resolveRepetitions(perTest: number | undefined, suite: SuiteState): number;
/**
* Initialize the suite: upload the dataset, create the experiment, and
* register the OpenInference tracer.
*
* If tracing is disabled (no Phoenix env vars, or PHOENIX_TEST_TRACKING=false),
* this populates a no-op tracer and exits without making any network calls.
*/
export declare function initializeSuite(suite: SuiteState): Promise<void>;
/**
* Wrap the user's test body in an OpenInference task span and return the
* trace id so we can submit it with the experiment run.
*/
export declare function runTaskWithTracing<Result>(suite: SuiteState, testName: string, fn: () => Promise<Result>): Promise<{
traceId: string;
result: Result;
} | {
traceId: string;
error: Error;
isTaskError: boolean;
}>;
/**
* End the current run's task span. `logOutput()` calls this immediately so
* evaluator work that follows is not included in the task span duration.
*/
export declare function endTaskSpanForRun(run: RunState): void;
/**
* POST a single experiment run for one test case to Phoenix.
*
* Best-effort: failures are captured and surfaced via the test reporter but
* do not fail the test itself.
*/
export declare function postExperimentRun(suite: SuiteState, run: RunState): Promise<string | undefined>;
/**
* POST one annotation (an "experiment_evaluation") for a run.
*/
export declare function postAnnotation(suite: SuiteState, runId: string | undefined, annotation: Annotation): Promise<void>;
/** Run an evaluator in an OpenInference evaluator span. */
export declare function runEvaluatorWithTracing<EvaluatorParams extends KVMap, EvaluatorResult>(suite: SuiteState, name: string, params: EvaluatorParams, fn: (params: EvaluatorParams) => EvaluatorResult | Promise<EvaluatorResult>): Promise<{
result: EvaluatorResult;
traceId: string | null;
}>;
/**
* Tear down the tracer provider created for the suite, flushing any pending
* spans before the process exits.
*/
export declare function teardownSuite(suite: SuiteState): Promise<void>;
/** Re-export the ones the entrypoint files consume. */
export type { GlobalTracerProviderRegistration, NodeTracerProvider };
//# sourceMappingURL=phoenix-test-tracking.d.ts.map