Skip to content

Commit

Permalink
Fetch single run spec rather than all run specs on predictions page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanmai authored Sep 25, 2024
1 parent ffacf06 commit 5d5ee71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 7 additions & 10 deletions helm-frontend/src/routes/Run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ArrowTopRightOnSquareIcon,
} from "@heroicons/react/24/solid";
import getSchema from "@/services/getSchema";
import getRunSpecs from "@/services/getRunSpecs";
import type RunSpec from "@/types/RunSpec";
import getInstances from "@/services/getInstances";
import type Instance from "@/types/Instance";
Expand All @@ -18,7 +17,9 @@ import getScenarioByName from "@/services/getScenarioByName";
import type Scenario from "@/types/Scenario";
import type AdapterFieldMap from "@/types/AdapterFieldMap";
import type MetricFieldMap from "@/types/MetricFieldMap";
import { getRunSpecByNameUrl } from "@/services/getRunSpecByName";
import getRunSpecByName, {
getRunSpecByNameUrl,
} from "@/services/getRunSpecByName";
import { getScenarioStateByNameUrl } from "@/services/getScenarioStateByName";
import Tab from "@/components/Tab";
import Tabs from "@/components/Tabs";
Expand Down Expand Up @@ -75,15 +76,15 @@ export default function Run() {
setRunSuite(suite);

const [
runSpecs,
runSpecResp,
instancesResp,
statsResp,
scenario,
displayPredictions,
displayRequests,
schema,
] = await Promise.all([
getRunSpecs(signal),
getRunSpecByName(runName, signal, suite),
getInstances(runName, signal, suite),
getStatsByName(runName, signal, suite),
getScenarioByName(runName, signal, suite),
Expand All @@ -92,7 +93,7 @@ export default function Run() {
getSchema(signal),
]);

setRunSpec(runSpecs.find((rs) => rs.name === runName));
setRunSpec(runSpecResp);
setInstances(instancesResp);
const totalInstancesPages = Math.ceil(
instancesResp.length / INSTANCES_PAGE_SIZE,
Expand Down Expand Up @@ -163,11 +164,7 @@ export default function Run() {
);

setModel(
schema.models.find(
(m) =>
m.name ===
runSpecs.find((rs) => rs.name === runName)?.adapter_spec.model,
),
schema.models.find((m) => m.name === runSpecResp?.adapter_spec.model),
);
}

Expand Down
5 changes: 4 additions & 1 deletion helm-frontend/src/services/getRunSpecByName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ export function getRunSpecByNameUrl(runName: string, suite?: string): string {
export default async function getRunSpecByName(
runName: string,
signal: AbortSignal,
suite?: string,
): Promise<RunSpec | undefined> {
try {
const runSpec = await fetch(getRunSpecByNameUrl(runName), { signal });
const runSpec = await fetch(getRunSpecByNameUrl(runName, suite), {
signal,
});

return (await runSpec.json()) as RunSpec;
} catch (error) {
Expand Down

0 comments on commit 5d5ee71

Please sign in to comment.