Skip to content

Commit

Permalink
[OPIK-424] [UX improvements] Improvements to experiment items table (#…
Browse files Browse the repository at this point in the history
…780)

* [OPIK-424] [UX improvements] Improvements to experiment items table

* - fix review comments
  • Loading branch information
andriidudar authored Dec 2, 2024
1 parent 0c3956f commit b9705b0
Show file tree
Hide file tree
Showing 26 changed files with 653 additions and 345 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const getFeedbackScoresNames = async (
{
signal,
params: {
withOnlyExperiments: true,
...(experimentsIds && { experiments_ids: experimentsIds }),
...(experimentsIds && {
experiment_ids: JSON.stringify(experimentsIds),
}),
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlaskConical } from "lucide-react";
import { HeaderContext } from "@tanstack/react-table";

import { Experiment, ExperimentsCompare } from "@/types/datasets";
import HeaderWrapper from "@/components/shared/DataTableHeaders/HeaderWrapper";

type CustomMeta = {
experiment?: Experiment;
Expand All @@ -19,13 +20,16 @@ const CompareExperimentsHeader: React.FunctionComponent<
const name = experiment?.name || experimentId;

return (
<div className="flex size-full items-center px-2">
<HeaderWrapper
metadata={context.column.columnDef.meta}
tableMetadata={context.table.options.meta}
>
{hasData && (
<div className="absolute left-0 top-0 h-[10000px] w-px bg-border" />
)}
<FlaskConical className="mr-2 size-4 shrink-0" />
<FlaskConical className="size-3.5 shrink-0 text-slate-300" />
<div className="comet-body-s-accented truncate">{name}</div>
</div>
</HeaderWrapper>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlaskConical } from "lucide-react";
import { HeaderContext } from "@tanstack/react-table";

import useExperimentById from "@/api/datasets/useExperimentById";
import HeaderWrapper from "@/components/shared/DataTableHeaders/HeaderWrapper";
import { FeedbackScoreData } from "@/components/pages/CompareExperimentsPage/helpers";

type CustomMeta = {
Expand All @@ -27,16 +28,16 @@ const ExperimentHeader: React.FunctionComponent<
const hasData = context.table.getRowCount() > 0;

return (
<div
className="flex size-full items-center justify-end px-2"
onClick={(e) => e.stopPropagation()}
<HeaderWrapper
metadata={context.column.columnDef.meta}
tableMetadata={context.table.options.meta}
>
{hasData && (
<div className="absolute left-0 top-0 h-[10000px] w-px bg-border" />
)}
<FlaskConical className="mr-2 size-4 shrink-0" />
<FlaskConical className="size-3.5 shrink-0 text-slate-300" />
<div className="comet-body-s-accented truncate">{name}</div>
</div>
</HeaderWrapper>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { convertColumnDataToColumn } from "@/lib/table";

import { COLUMN_TYPE } from "@/types/shared";
import ExperimentHeader from "@/components/pages/CompareExperimentsPage/CompareExperimentsPanel/FeedbackScoresTab/ExperimentHeader";
import FeedbackScoreCell from "@/components/pages/CompareExperimentsPage/CompareExperimentsPanel/FeedbackScoresTab/FeedbackScoreCell";
import FeedbackScoreNameCell from "@/components/shared/DataTableCells/FeedbackScoreNameCell";
import TextCell from "@/components/shared/DataTableCells/TextCell";

interface FeedbackScoresTabProps {
Expand Down Expand Up @@ -43,7 +43,7 @@ const FeedbackScoresTab = ({ experimentItems }: FeedbackScoresTabProps) => {
id: "name",
label: "Feedback score",
type: COLUMN_TYPE.numberDictionary,
cell: FeedbackScoreCell as never,
cell: FeedbackScoreNameCell as never,
},
],
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CompareConfigCell: React.FunctionComponent<
tableMetadata={{
...context.table.options.meta,
rowHeight: ROW_HEIGHT.small,
rowHeightClass: "min-h-14",
rowHeightStyle: { minHeight: "52px" },
}}
className="p-1.5"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { COLUMN_TYPE, ColumnData } from "@/types/shared";
import DataTable from "@/components/shared/DataTable/DataTable";
import DataTableNoData from "@/components/shared/DataTableNoData/DataTableNoData";
import TextCell from "@/components/shared/DataTableCells/TextCell";
import TagCell from "@/components/shared/DataTableCells/TagCell";
import FeedbackScoreNameCell from "@/components/shared/DataTableCells/FeedbackScoreNameCell";
import CompareExperimentsHeader from "@/components/pages/CompareExperimentsPage/CompareExperimentsHeader";
import CompareExperimentsActionsPanel from "@/components/pages/CompareExperimentsPage/CompareExperimentsActionsPanel";
import Loader from "@/components/shared/Loader/Loader";
Expand All @@ -25,7 +25,7 @@ export const DEFAULT_COLUMNS: ColumnData<FeedbackScoreData>[] = [
id: "name",
label: "Feedback score",
type: COLUMN_TYPE.numberDictionary,
cell: TagCell as never,
cell: FeedbackScoreNameCell as never,
size: 248,
},
];
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from "react";
import { CellContext } from "@tanstack/react-table";

import { ExperimentItem, ExperimentsCompare } from "@/types/datasets";
import VerticallySplitCellWrapper, {
CustomMeta,
} from "@/components/pages/CompareExperimentsPage/ExperimentItemsTab/VerticallySplitCellWrapper";
import TooltipWrapper from "@/components/shared/TooltipWrapper/TooltipWrapper";
import { MessageSquareMore } from "lucide-react";

const CompareExperimentsFeedbackScoreCell: React.FunctionComponent<
CellContext<ExperimentsCompare, unknown>
> = (context) => {
const experimentCompare = context.row.original;
const { custom } = context.column.columnDef.meta ?? {};
const { feedbackKey } = (custom ?? {}) as CustomMeta;

const renderContent = (item: ExperimentItem | undefined) => {
const feedbackScore = item?.feedback_scores?.find(
(f) => f.name === feedbackKey,
);

if (!feedbackScore) {
return <div className="flex h-4 w-full items-center justify-end">-</div>;
}

return (
<div className="flex h-4 w-full items-center justify-end gap-1">
<div className="truncate">{feedbackScore.value}</div>
{feedbackScore.reason && (
<TooltipWrapper content={feedbackScore.reason} delayDuration={100}>
<MessageSquareMore className="size-3.5 shrink-0 text-light-slate" />
</TooltipWrapper>
)}
</div>
);
};

return (
<VerticallySplitCellWrapper
renderContent={renderContent}
experimentCompare={experimentCompare}
metadata={context.column.columnDef.meta}
tableMetadata={context.table.options.meta}
rowId={context.row.id}
></VerticallySplitCellWrapper>
);
};

export default CompareExperimentsFeedbackScoreCell;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from "react";
import { CellContext } from "@tanstack/react-table";

import { ExperimentItem, ExperimentsCompare } from "@/types/datasets";
import VerticallySplitCellWrapper, {
CustomMeta,
} from "@/components/pages/CompareExperimentsPage/ExperimentItemsTab/VerticallySplitCellWrapper";
import ResourceLink, {
RESOURCE_TYPE,
} from "@/components/shared/ResourceLink/ResourceLink";

const CompareExperimentsOutputCell: React.FunctionComponent<
CellContext<ExperimentsCompare, unknown>
> = (context) => {
const { custom } = context.column.columnDef.meta ?? {};
const { experiments = [] } = (custom ?? {}) as CustomMeta;
const experimentCompare = context.row.original;

const renderContent = (
item: ExperimentItem | undefined,
experimentId: string,
) => {
const experiment = experiments.find((e) => e.id === experimentId);

return (
<div className="-mt-2 h-8">
<ResourceLink
id={experiment?.dataset_id || ""}
name={experiment?.name}
resource={RESOURCE_TYPE.experiment}
search={{
experiments: [experimentId],
}}
/>
</div>
);
};

return (
<VerticallySplitCellWrapper
renderContent={renderContent}
experimentCompare={experimentCompare}
metadata={context.column.columnDef.meta}
tableMetadata={context.table.options.meta}
rowId={context.row.id}
></VerticallySplitCellWrapper>
);
};

export default CompareExperimentsOutputCell;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { FlaskConical } from "lucide-react";
import { HeaderContext } from "@tanstack/react-table";

import { ExperimentsCompare } from "@/types/datasets";
import HeaderWrapper from "@/components/shared/DataTableHeaders/HeaderWrapper";

const CompareExperimentsNameHeader: React.FunctionComponent<
HeaderContext<ExperimentsCompare, unknown>
> = (context) => {
const hasData = context.table.getRowCount() > 0;

return (
<HeaderWrapper
metadata={context.column.columnDef.meta}
tableMetadata={context.table.options.meta}
>
{hasData && (
<div className="absolute left-0 top-0 h-[10000px] w-px bg-border" />
)}
<FlaskConical className="size-3.5 shrink-0 text-slate-300" />
<div className="comet-body-s-accented truncate">Experiment</div>
</HeaderWrapper>
);
};

export default CompareExperimentsNameHeader;
Loading

0 comments on commit b9705b0

Please sign in to comment.