Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate experiment list api [DET-3696, DET-3697, DET-3698] #1228

Merged
merged 15 commits into from
Sep 2, 2020
Merged
20 changes: 13 additions & 7 deletions webui/react/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Auth from 'contexts/Auth';
import ClusterOverview from 'contexts/ClusterOverview';
import { Commands, Notebooks, Shells, Tensorboards } from 'contexts/Commands';
import Users from 'contexts/Users';
import { ErrorType } from 'ErrorHandler';
import handleError from 'ErrorHandler';
import usePolling from 'hooks/usePolling';
import useStorage from 'hooks/useStorage';
import { getExperimentList } from 'services/api';
Expand Down Expand Up @@ -60,13 +62,17 @@ const Dashboard: React.FC = () => {
const [ filters, setFilters ] = useState<TaskFilters>(initFilters);

const fetchExperiments = useCallback(async (): Promise<void> => {
const response = await getExperimentList(
{ descend: true, key: 'startTime' },
{ limit: 100, offset: 0 },
{ showArchived: false, states: filters.states, username: filters.username },
);
const experiments = decodeExperimentList(response.experiments || []);
setExperiments(experiments);
try {
const response = await getExperimentList(
{ descend: true, key: 'startTime' },
{ limit: 100, offset: 0 },
{ showArchived: false, states: filters.states, username: filters.username },
);
const experiments = decodeExperimentList(response.experiments || []);
setExperiments(experiments);
} catch (e) {
handleError({ message: 'Unable to fetch experiments.', silent: true, type: ErrorType.Api });
justin-determined-ai marked this conversation as resolved.
Show resolved Hide resolved
}
}, [ filters, setExperiments ]);

usePolling(fetchExperiments);
Expand Down
12 changes: 8 additions & 4 deletions webui/react/src/pages/ExperimentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ const ExperimentList: React.FC = () => {
}, [ selectedExperiments ]);

const fetchExperiments = useCallback(async (): Promise<void> => {
const response = await getExperimentList(sorter, pagination, filters, search);
const experiments = decodeExperimentList(response.experiments || []);
setTotal(response.pagination?.total || 0);
setExperiments(experiments);
try {
const response = await getExperimentList(sorter, pagination, filters, search);
hamidzr marked this conversation as resolved.
Show resolved Hide resolved
const experiments = decodeExperimentList(response.experiments || []);
hamidzr marked this conversation as resolved.
Show resolved Hide resolved
setTotal(response.pagination?.total || 0);
setExperiments(experiments);
} catch (e) {
handleError({ message: 'Unable to fetch experiments.', silent: true, type: ErrorType.Api });
}
}, [ filters, pagination, search, sorter ]);

usePolling(fetchExperiments);
Expand Down