-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into thiagohora/OPIK-138_add_last_updated_trace_a…
…t_field
- Loading branch information
Showing
16 changed files
with
522 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 112 additions & 3 deletions
115
apps/opik-frontend/e2e/tests/traces/traces-table.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,127 @@ | ||
import { expect, test } from "@e2e/fixtures"; | ||
import { SPAN_1, TRACE_SCORE } from "@e2e/test-data"; | ||
import { FeedbackScoreData } from "@e2e/entities"; | ||
|
||
test.describe("Traces table", () => { | ||
test("Check trace/span creation", async ({ | ||
test("Check data visibility", async ({ | ||
project, | ||
trace1, | ||
span, | ||
tracesPage, | ||
}) => { | ||
await trace1.addScore(TRACE_SCORE as FeedbackScoreData); | ||
await tracesPage.goto(project.id); | ||
await expect(tracesPage.title).toBeVisible(); | ||
await tracesPage.table.checkIsExist(trace1.name); | ||
await tracesPage.columns.selectAll(); | ||
const timeFormat = | ||
/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{2} (0[1-9]|1[0-2]):[0-5][0-9] (AM|PM)$/; | ||
|
||
// test traces visibility | ||
const traceData = trace1.original as { | ||
id: string; | ||
input: object; | ||
output: object; | ||
metadata: object; | ||
tags: string[]; | ||
}; | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "id"), | ||
).toHaveText(`${traceData.id.slice(0, 6)}...`); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "start_time"), | ||
).toHaveText(timeFormat); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "end_time"), | ||
).toHaveText(timeFormat); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "input"), | ||
).toHaveText(JSON.stringify(traceData.input, null, 2)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "output"), | ||
).toHaveText(JSON.stringify(traceData.output, null, 2)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "metadata"), | ||
).toHaveText(JSON.stringify(traceData.metadata, null, 2)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "feedback_scores"), | ||
).toHaveText(TRACE_SCORE.name + TRACE_SCORE.value); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(trace1.name, "tags"), | ||
).toHaveText(traceData.tags.sort().join("")); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId( | ||
trace1.name, | ||
"usage_total_tokens", | ||
), | ||
).toHaveText(String(SPAN_1.usage.total_tokens)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId( | ||
trace1.name, | ||
"usage_prompt_tokens", | ||
), | ||
).toHaveText(String(SPAN_1.usage.prompt_tokens)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId( | ||
trace1.name, | ||
"usage_completion_tokens", | ||
), | ||
).toHaveText(String(SPAN_1.usage.completion_tokens)); | ||
|
||
await tracesPage.switchToLLMCalls(); | ||
await tracesPage.table.checkIsNotExist(trace1.name); | ||
await tracesPage.table.checkIsExist(span.name); | ||
|
||
// test spans visibility | ||
const spanData = span.original as { | ||
id: string; | ||
name: string; | ||
output: object; | ||
tags: string[]; | ||
}; | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "id"), | ||
).toHaveText(`${spanData.id.slice(0, 6)}...`); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "start_time"), | ||
).toHaveText(timeFormat); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "end_time"), | ||
).toHaveText(timeFormat); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "output"), | ||
).toHaveText(JSON.stringify(spanData.output, null, 2)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "tags"), | ||
).toHaveText(spanData.tags.sort().join("")); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "usage_total_tokens"), | ||
).toHaveText(String(SPAN_1.usage.total_tokens)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId(span.name, "usage_prompt_tokens"), | ||
).toHaveText(String(SPAN_1.usage.prompt_tokens)); | ||
|
||
await expect( | ||
tracesPage.table.getCellLocatorByCellId( | ||
span.name, | ||
"usage_completion_tokens", | ||
), | ||
).toHaveText(String(SPAN_1.usage.completion_tokens)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
apps/opik-frontend/src/components/pages/ExperimentsPage/ExperimentRowActionsCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
import { Button } from "@/components/ui/button"; | ||
import { MoreHorizontal, Trash } from "lucide-react"; | ||
import React, { useCallback, useRef, useState } from "react"; | ||
import { CellContext } from "@tanstack/react-table"; | ||
import ConfirmDialog from "@/components/shared/ConfirmDialog/ConfirmDialog"; | ||
import { Experiment } from "@/types/datasets"; | ||
import useExperimentBatchDeleteMutation from "@/api/datasets/useExperimentBatchDeleteMutation"; | ||
|
||
export const ExperimentRowActionsCell: React.FunctionComponent< | ||
CellContext<Experiment, unknown> | ||
> = ({ row }) => { | ||
const resetKeyRef = useRef(0); | ||
const experiment = row.original; | ||
const [open, setOpen] = useState<boolean>(false); | ||
|
||
const experimentBatchDeleteMutation = useExperimentBatchDeleteMutation(); | ||
|
||
const deleteExperimentsHandler = useCallback(() => { | ||
experimentBatchDeleteMutation.mutate({ | ||
ids: [experiment.id], | ||
}); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [experiment]); | ||
|
||
return ( | ||
<div | ||
className="flex size-full items-center justify-end" | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
<ConfirmDialog | ||
key={`delete-${resetKeyRef.current}`} | ||
open={open} | ||
setOpen={setOpen} | ||
onConfirm={deleteExperimentsHandler} | ||
title={`Delete ${experiment.name}`} | ||
description="Are you sure you want to delete this experiment?" | ||
confirmText="Delete experiment" | ||
/> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="minimal" size="icon"> | ||
<span className="sr-only">Actions menu</span> | ||
<MoreHorizontal className="size-4" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end" className="w-52"> | ||
<DropdownMenuItem | ||
onClick={() => { | ||
setOpen(true); | ||
resetKeyRef.current = resetKeyRef.current + 1; | ||
}} | ||
> | ||
<Trash className="mr-2 size-4" /> | ||
Delete | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.