Skip to content

Commit 91c96d1

Browse files
author
Daniel Duong
committed
fix(autorag/results): align results page
1 parent 1f922d9 commit 91c96d1

4 files changed

Lines changed: 43 additions & 43 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
function AutoragResults(): React.JSX.Element {
4-
return <div>results</div>;
4+
return <></>;
55
}
66

77
export default AutoragResults;

packages/autorag/frontend/src/app/hooks/queries.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
11
import { useQuery, UseQueryResult } from '@tanstack/react-query';
22
import { getLlamaStackModels } from '~/app/api/k8s';
3-
import { LlamaStackModelType, LlamaStackModelsResponse } from '~/app/types';
4-
5-
export function useExperimentsQuery(): UseQueryResult<never[], Error> {
6-
return useQuery({
7-
queryKey: ['experiments'],
8-
queryFn: async () => {
9-
const experiments: never[] = [];
10-
return experiments;
11-
},
12-
});
13-
}
14-
15-
export function useExperimentQuery(
16-
experimentId?: string,
17-
): UseQueryResult<{ display_name: string }, Error> {
18-
return useQuery({
19-
queryKey: ['experiments', experimentId],
20-
queryFn: async () => {
21-
// eslint-disable-next-line camelcase
22-
const experiment = { display_name: 'FAKE_EXPERIMENT_NAME' };
23-
return experiment;
24-
},
25-
enabled: !!experimentId,
26-
});
27-
}
3+
import { LlamaStackModelsResponse, LlamaStackModelType } from '~/app/types';
284

295
export function useLlamaStackModelsQuery(
306
namespace: string,
@@ -42,12 +18,12 @@ export function useLlamaStackModelsQuery(
4218

4319
export function usePipelineRunQuery(
4420
runId?: string,
45-
): UseQueryResult<{ experiment_id: string }, Error> {
21+
): UseQueryResult<{ display_name: string }, Error> {
4622
return useQuery({
4723
queryKey: ['pipelineRun', runId],
4824
queryFn: async () => {
4925
// eslint-disable-next-line camelcase
50-
const pipelineRun = { experiment_id: 'FAKE_EXPERIMENT_ID' };
26+
const pipelineRun = { display_name: 'RUN_NAME' };
5127
return pipelineRun;
5228
},
5329
enabled: !!runId,

packages/autorag/frontend/src/app/pages/AutoragConfigurePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ function AutoragConfigurePage(): React.JSX.Element {
4343
const invalidNamespace =
4444
namespacesLoaded && !!namespace && !namespaces.map((ns) => ns.name).includes(namespace);
4545

46-
const pipelineRunsMutation = usePipelineRunsMutation(namespace ?? '');
47-
4846
const getRedirectPath = (ns: string) => `${autoragExperimentsPathname}/${ns}`;
4947

48+
const pipelineRunsMutation = usePipelineRunsMutation(namespace ?? '');
49+
5050
const form = useForm({
5151
mode: 'onChange',
5252
resolver: zodResolver(configureSchema.full),

packages/autorag/frontend/src/app/pages/AutoragResultsPage.tsx

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
1-
import { ApplicationsPage } from 'mod-arch-shared';
1+
import { Breadcrumb, BreadcrumbItem } from '@patternfly/react-core';
2+
import { useNamespaceSelector } from 'mod-arch-core';
3+
import { ApplicationsPage, ProjectObjectType, TitleWithIcon } from 'mod-arch-shared';
24
import React from 'react';
3-
import { useParams } from 'react-router';
4-
import AutoragResults from '~/app/components/results/AutoragResults';
5-
import { useExperimentQuery, usePipelineRunQuery } from '~/app/hooks/queries';
5+
import { Link, useParams } from 'react-router';
66
import InvalidPipelineRun from '~/app/components/empty-states/InvalidPipelineRun';
7+
import AutoragResults from '~/app/components/results/AutoragResults';
8+
import { usePipelineRunQuery } from '~/app/hooks/queries';
9+
import InvalidProject from '../components/empty-states/InvalidProject';
10+
import { autoragExperimentsPathname } from '../utilities/routes';
711

812
function AutoragResultsPage(): React.JSX.Element {
913
const { runId } = useParams();
1014

11-
const { data: pipelineRun, ...pipelineRunQuery } = usePipelineRunQuery(runId);
12-
const { data: experiment, ...experimentQuery } = useExperimentQuery(pipelineRun?.experiment_id);
15+
const { namespace } = useParams();
16+
const { namespaces, namespacesLoaded, namespacesLoadError } = useNamespaceSelector();
1317

18+
const noNamespaces = namespacesLoaded && namespaces.length === 0;
19+
const invalidNamespace =
20+
namespacesLoaded && !!namespace && !namespaces.map((ns) => ns.name).includes(namespace);
21+
22+
const getRedirectPath = (ns: string) => `${autoragExperimentsPathname}/${ns}`;
23+
24+
const { data: pipelineRun, ...pipelineRunQuery } = usePipelineRunQuery(runId);
1425
const invalidPipelineRunId = pipelineRunQuery.isError;
1526

1627
return (
1728
<ApplicationsPage
18-
title={experiment?.display_name}
19-
empty={invalidPipelineRunId}
20-
emptyStatePage={<InvalidPipelineRun />}
21-
loadError={pipelineRunQuery.error ?? experimentQuery.error ?? undefined}
22-
loaded={pipelineRunQuery.isFetched && experimentQuery.isFetched}
23-
provideChildrenPadding
24-
removeChildrenTopPadding
29+
title={<TitleWithIcon title="AutoRAG" objectType={ProjectObjectType.pipelineExperiment} />}
30+
subtext={<h2 className="pf-v6-u-mt-sm">{`"${pipelineRun?.display_name}" results`}</h2>}
31+
breadcrumb={
32+
<Breadcrumb>
33+
<BreadcrumbItem>
34+
<Link to={getRedirectPath(namespace!)}>AutoRAG: {namespace}</Link>
35+
</BreadcrumbItem>
36+
<BreadcrumbItem isActive>{pipelineRun?.display_name}</BreadcrumbItem>
37+
</Breadcrumb>
38+
}
39+
empty={noNamespaces || invalidNamespace || invalidPipelineRunId}
40+
emptyStatePage={
41+
invalidPipelineRunId ? (
42+
<InvalidPipelineRun />
43+
) : (
44+
<InvalidProject namespace={namespace} getRedirectPath={getRedirectPath} />
45+
)
46+
}
47+
loadError={pipelineRunQuery.error ?? namespacesLoadError}
48+
loaded={namespacesLoaded && pipelineRunQuery.isFetched}
2549
>
2650
<AutoragResults />
2751
</ApplicationsPage>

0 commit comments

Comments
 (0)