🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(worker): export eval job configurations in core data S3 export (#15167)
Max Deichmanna19d37f487ea
diff --git a/worker/src/queues/__tests__/coreDataS3ExportQueue.test.ts b/worker/src/queues/__tests__/coreDataS3ExportQueue.test.tsindex 11c7cf3f46..9bd115d6cf 100644--- a/worker/src/queues/__tests__/coreDataS3ExportQueue.test.ts+++ b/worker/src/queues/__tests__/coreDataS3ExportQueue.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vitest";import { Readable } from "node:stream";import { type StorageService } from "@langfuse/shared/src/server";import {+ mapJobConfigurationToCoreDataRow,mapUserToCoreDataRow,uploadTableCoreDataJsonl,} from "../coreDataS3ExportQueue";@@ -48,6 +49,45 @@ describe("mapUserToCoreDataRow", () => {});});+describe("mapJobConfigurationToCoreDataRow", () => {+ const decimal = (value: number) => ({ toNumber: () => value });++ it("flattens the eval template and casts sampling to a number", () => {+ const row = mapJobConfigurationToCoreDataRow({+ id: "config-1",+ projectId: "project-1",+ scoreName: "toxicity",+ evalTemplateId: "template-1",+ evalTemplate: { name: "toxicity-v2" },+ sampling: decimal(0.5),+ });++ expect(row).toStrictEqual({+ id: "config-1",+ projectId: "project-1",+ scoreName: "toxicity",+ evalTemplateId: "template-1",+ evalTemplateName: "toxicity-v2",+ sampling: 0.5,+ });+ expect(JSON.stringify(row)).toContain('"sampling":0.5');+ });++ it("exports null for configurations without an eval template", () => {+ const row = mapJobConfigurationToCoreDataRow({+ id: "config-2",+ evalTemplate: null,+ sampling: decimal(1),+ });++ expect(row).toStrictEqual({+ id: "config-2",+ evalTemplateName: null,+ sampling: 1,+ });+ });+});+describe("uploadTableCoreDataJsonl", () => {const createS3Client = (uploadFileBuffered: ReturnType<typeof vi.fn>,diff --git a/worker/src/queues/coreDataS3ExportQueue.ts b/worker/src/queues/coreDataS3ExportQueue.tsindex ff6df399ca..a5d8663cac 100644--- a/worker/src/queues/coreDataS3ExportQueue.ts+++ b/worker/src/queues/coreDataS3ExportQueue.ts@@ -56,6 +56,24 @@ export const mapUserToCoreDataRow = ({],});+type JobConfigurationCoreDataInput = {+ evalTemplate: { name: string } | null;+ sampling: { toNumber: () => number };+} & Record<string, unknown>;++// Flattens the joined eval template into a plain column so the export stays+// one JSONL row per configured evaluator. The sampling Decimal is cast to a+// JS number so it lands as a JSON number instead of a quoted string.+export const mapJobConfigurationToCoreDataRow = ({+ evalTemplate,+ sampling,+ ...jobConfiguration+}: JobConfigurationCoreDataInput) => ({+ ...jobConfiguration,+ sampling: sampling.toNumber(),+ evalTemplateName: evalTemplate?.name ?? null,+});+type TablePageArgs<TCursor> = {lastRow: TCursor | null;take: number;@@ -422,6 +440,43 @@ const coreDataTableExports: Array<},}),}),+ (args) =>+ uploadTableCoreDataJsonl({+ ...args,+ tableName: "jobConfigurations",+ // blockMessage is excluded as free-text; the eval template relation is+ // flattened to evalTemplateName below+ fetchPage: ({ lastRow, take }: TablePageArgs<{ id: string }>) =>+ prisma.jobConfiguration.findMany({+ take,+ ...(lastRow ? { cursor: { id: lastRow.id }, skip: 1 } : {}),+ orderBy: { id: "asc" },+ select: {+ id: true,+ projectId: true,+ jobType: true,+ status: true,+ blockedAt: true,+ blockReason: true,+ evalTemplateId: true,+ scoreName: true,+ filter: true,+ targetObject: true,+ variableMapping: true,+ sampling: true,+ delay: true,+ timeScope: true,+ createdAt: true,+ updatedAt: true,+ evalTemplate: {+ select: {+ name: true,+ },+ },+ },+ }),+ mapRow: mapJobConfigurationToCoreDataRow,+ }),];export const coreDataS3ExportProcessor: Processor = async (): Promise<void> => {