Skip to content

Commit

Permalink
fix: load trial data for single run searches in search view #9742 (#9752
Browse files Browse the repository at this point in the history
)

Co-authored-by: Ashton Galloway <[email protected]>
  • Loading branch information
dannysauer and ashtonG authored Jul 29, 2024
1 parent 41a512e commit 623c945
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const ExperimentSingleTrialTabs: React.FC<Props> = ({
// make sure the experiment is in terminal state before the request is made.
const isTerminalExp = terminalRunStates.has(experiment.state);
const expTrials = await getExpTrials(
{ id: experiment.id, limit: 2 },
{ id: experiment.id, limit: 1 },
{ signal: canceler.signal },
);
const firstTrial = expTrials.trials[0];
Expand Down
35 changes: 32 additions & 3 deletions webui/react/src/pages/SearchDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Pivot, { PivotProps } from 'hew/Pivot';
import Notes from 'hew/RichTextEditor';
import { Loadable } from 'hew/utils/loadable';
import { Loadable, NotLoaded } from 'hew/utils/loadable';
import { string } from 'io-ts';
import _ from 'lodash';
import { useObservable } from 'micro-observables';
Expand All @@ -9,14 +9,16 @@ import { unstable_useBlocker, useLocation, useNavigate, useParams } from 'react-

import Page, { BreadCrumbRoute } from 'components/Page';
import { terminalRunStates } from 'constants/states';
import { useAsync } from 'hooks/useAsync';
import usePermissions from 'hooks/usePermissions';
import usePolling from 'hooks/usePolling';
import { SettingsConfig, useSettings } from 'hooks/useSettings';
import { paths } from 'routes/utils';
import { getExperimentDetails, patchExperiment } from 'services/api';
import { getExperimentDetails, getExpTrials, patchExperiment } from 'services/api';
import workspaceStore from 'stores/workspaces';
import { ExperimentBase, Note, ValueOf, Workspace } from 'types';
import { ExperimentBase, Note, TrialItem, ValueOf, Workspace } from 'types';
import handleError, { ErrorLevel, ErrorType } from 'utils/error';
import { isSingleTrialExperiment } from 'utils/experiment';
import { isAborted, isNotFound } from 'utils/service';

import ExperimentCodeViewer from './ExperimentDetails/ExperimentCodeViewer';
Expand Down Expand Up @@ -120,6 +122,32 @@ const SearchDetails: React.FC = () => {
}
}, [pageError, searchId]);

const singleTrialData = useAsync<TrialItem | undefined>(
async (canceler) => {
if (!experiment || !isSingleTrialExperiment(experiment)) {
return NotLoaded;
}
try {
const trialsResponse = await getExpTrials(
{ id: experiment.id, limit: 2 },
{ signal: canceler.signal },
);
return trialsResponse.trials[0];
} catch (e) {
if (!canceler.signal.aborted) {
handleError(e, {
level: ErrorLevel.Error,
publicMessage: 'Failed to fetch run information for search',
silent: false,
type: ErrorType.Server,
});
}
}
return NotLoaded;
},
[experiment],
);

const handleNotesUpdate = useCallback(
async (notes: Note) => {
const editedNotes = notes.contents;
Expand Down Expand Up @@ -237,6 +265,7 @@ const SearchDetails: React.FC = () => {
<ExperimentDetailsHeader
experiment={experiment}
fetchExperimentDetails={fetchExperimentDetails}
trial={singleTrialData.getOrElse(undefined)}
/>
)
}
Expand Down

0 comments on commit 623c945

Please sign in to comment.