未验证 提交 2d46c45a 编写于 作者: P Peter Pan 提交者: GitHub

chore: remove unused api (#742, #743) (#747)

上级 4049f980
import {Run, Tag, TagWithSingleRun} from '~/types';
import {Run, Tag, TagWithSingleRun, TagsData} from '~/types';
import {color, colorAlt} from '~/utils/chart';
import {useCallback, useEffect, useMemo, useReducer} from 'react';
......@@ -142,8 +142,23 @@ const reducer = (state: State, action: Action): State => {
const useTagFilter = (type: string, running: boolean) => {
const router = useRouter();
const {data: runs, loading: loadingRuns} = useRunningRequest<string[]>('/runs', running);
const {data: tags, loading: loadingTags} = useRunningRequest<Tags>(`/${type}/tags`, running);
const {data, loading, error} = useRunningRequest<TagsData>(`/${type}/tags`, running);
const runs: string[] = useMemo(() => data?.runs ?? [], [data]);
const tags: Tags = useMemo(
() =>
data
? runs.reduce<Tags>((m, run, i) => {
if (m[run]) {
m[run] = [...m[run], ...(data.tags?.[i] ?? [])];
} else {
m[run] = data.tags[i] ?? [];
}
return m;
}, {})
: {},
[runs, data]
);
const [state, dispatch] = useReducer(reducer, {
initRuns: [],
......@@ -197,8 +212,8 @@ const useTagFilter = (type: string, running: boolean) => {
runsInTags,
onChangeRuns,
onChangeTags,
loadingRuns,
loadingTags
loading,
error
};
};
......
......@@ -16,6 +16,7 @@ import RadioButton from '~/components/RadioButton';
import RadioGroup from '~/components/RadioGroup';
import RunningToggle from '~/components/RunningToggle';
import SearchInput from '~/components/SearchInput';
import {TagsData} from '~/types';
import Title from '~/components/Title';
import styled from 'styled-components';
import {useRouter} from 'next/router';
......@@ -52,25 +53,17 @@ const HighDimensional: NextI18NextPage = () => {
const [running, setRunning] = useState(true);
const {data: runs, error: runsError, loading: runsLoading} = useRunningRequest<string[]>('/runs', running);
const {data: tags, error: tagsError, loading: tagsLoading} = useRunningRequest<Record<string, string[]>>(
'/embedding/tags',
running
);
const error = useMemo(() => runsError || tagsError, [runsError, tagsError]);
const loading = useMemo(() => runsLoading || tagsLoading, [runsLoading, tagsLoading]);
const {data, error, loading} = useRunningRequest<TagsData>('/embedding/tags', running);
const list = useMemo(() => {
if (!runs || !tags) {
if (!data) {
return [];
}
return runs.reduce<Item[]>(
(p, run) => [...p, ...(tags[run]?.map(tag => ({run, tag, label: `${run}/${tag}`})) ?? [])],
return data.runs.reduce<Item[]>(
(p, run, i) => [...p, ...(data.tags[i]?.map(tag => ({run, tag, label: `${run}/${tag}`})) ?? [])],
[]
);
}, [runs, tags]);
}, [data]);
const labelList = useMemo(() => list.map(item => item.label), [list]);
const {query} = useRouter();
......@@ -150,7 +143,7 @@ const HighDimensional: NextI18NextPage = () => {
return (
<>
<Preloader url="/runs" />
<Preloader url="/embedding/tags" />
<Title>{t('common:high-dimensional')}</Title>
<Content aside={aside} loading={loading}>
{!loading && !list.length ? (
......
......@@ -21,10 +21,7 @@ const Histogram: NextI18NextPage = () => {
const [running, setRunning] = useState(true);
const {runs, tagsWithSingleRun, selectedRuns, onChangeRuns, loadingRuns, loadingTags} = useTagFilter(
'histogram',
running
);
const {runs, tagsWithSingleRun, selectedRuns, onChangeRuns, loading} = useTagFilter('histogram', running);
const [mode, setMode] = useState<Modes>(Modes.Offset);
......@@ -61,14 +58,13 @@ const Histogram: NextI18NextPage = () => {
return (
<>
<Preloader url="/runs" />
<Preloader url="/histogram/tags" />
<Title>{t('common:histogram')}</Title>
<Content aside={aside} loading={loadingRuns}>
{!loadingRuns && !runs.length ? (
<Content aside={aside} loading={loading}>
{!loading && !runs.length ? (
<Error />
) : (
<ChartPage items={tagsWithSingleRun} withChart={withChart} loading={loadingRuns || loadingTags} />
<ChartPage items={tagsWithSingleRun} withChart={withChart} loading={loading} />
)}
</Content>
</>
......
......@@ -48,10 +48,7 @@ const PRCurve: NextI18NextPage = () => {
const [running, setRunning] = useState(true);
const {runs, tags, runsInTags, selectedRuns, onChangeRuns, loadingRuns, loadingTags} = useTagFilter(
'pr-curve',
running
);
const {runs, tags, runsInTags, selectedRuns, onChangeRuns, loading} = useTagFilter('pr-curve', running);
const [indexes, setIndexes] = useState<Record<string, number>>({});
const onChangeIndexes = useCallback(
......@@ -148,14 +145,13 @@ const PRCurve: NextI18NextPage = () => {
return (
<>
<Preloader url="/runs" />
<Preloader url="/pr-curve/tags" />
<Title>{t('common:pr-curve')}</Title>
<Content aside={aside} loading={loadingRuns}>
{!loadingRuns && !runs.length ? (
<Content aside={aside} loading={loading}>
{!loading && !runs.length ? (
<Error />
) : (
<ChartPage items={prCurveTags} withChart={withChart} loading={loadingRuns || loadingTags} />
<ChartPage items={prCurveTags} withChart={withChart} loading={loading} />
)}
</Content>
</>
......
......@@ -35,10 +35,7 @@ const Audio: NextI18NextPage = () => {
const [running, setRunning] = useState(true);
const {runs, tagsWithSingleRun, selectedRuns, onChangeRuns, loadingRuns, loadingTags} = useTagFilter(
'audio',
running
);
const {runs, tagsWithSingleRun, selectedRuns, onChangeRuns, loading} = useTagFilter('audio', running);
const aside = useMemo(
() =>
......@@ -61,20 +58,19 @@ const Audio: NextI18NextPage = () => {
return (
<>
<Preloader url="/runs" />
<Preloader url="/audio/tags" />
<Title>
{t('common:sample')} - {t('common:audio')}
</Title>
<Content aside={aside} loading={loadingRuns}>
{!loadingRuns && !runs.length ? (
<Content aside={aside} loading={loading}>
{!loading && !runs.length ? (
<Error />
) : (
<ChartPage
items={tagsWithSingleRun}
chartSize={chartSize}
withChart={withChart}
loading={loadingRuns || loadingTags}
loading={loading}
/>
)}
</Content>
......
......@@ -26,10 +26,7 @@ const Image: NextI18NextPage = () => {
const [running, setRunning] = useState(true);
const {runs, tagsWithSingleRun, selectedRuns, onChangeRuns, loadingRuns, loadingTags} = useTagFilter(
'image',
running
);
const {runs, tagsWithSingleRun, selectedRuns, onChangeRuns, loading} = useTagFilter('image', running);
const [showActualSize, setShowActualSize] = useState(false);
const [brightness, setBrightness] = useState(1);
......@@ -81,20 +78,19 @@ const Image: NextI18NextPage = () => {
return (
<>
<Preloader url="/runs" />
<Preloader url="/image/tags" />
<Title>
{t('common:sample')} - {t('common:image')}
</Title>
<Content aside={aside} loading={loadingRuns}>
{!loadingRuns && !runs.length ? (
<Content aside={aside} loading={loading}>
{!loading && !runs.length ? (
<Error />
) : (
<ChartPage
items={tagsWithSingleRun}
chartSize={chartSize}
withChart={withChart}
loading={loadingRuns || loadingTags}
loading={loading}
/>
)}
</Content>
......
......@@ -37,7 +37,7 @@ const Scalar: NextI18NextPage = () => {
const [running, setRunning] = useState(true);
const {runs, tags, selectedRuns, onChangeRuns, loadingRuns, loadingTags} = useTagFilter('scalar', running);
const {runs, tags, selectedRuns, onChangeRuns, loading} = useTagFilter('scalar', running);
const [smoothing, setSmoothing] = useState(0.6);
......@@ -106,14 +106,13 @@ const Scalar: NextI18NextPage = () => {
return (
<>
<Preloader url="/runs" />
<Preloader url="/scalar/tags" />
<Title>{t('common:scalar')}</Title>
<Content aside={aside} loading={loadingRuns}>
{!loadingRuns && !runs.length ? (
<Content aside={aside} loading={loading}>
{!loading && !runs.length ? (
<Error />
) : (
<ChartPage items={tags} withChart={withChart} loading={loadingRuns || loadingTags} />
<ChartPage items={tags} withChart={withChart} loading={loading} />
)}
</Content>
</>
......
export interface TagsData {
runs: string[];
tags: string[][];
}
export interface Run {
label: string;
colors: [string, string];
......
......@@ -2,7 +2,6 @@ import type {Worker} from './types';
const worker: Worker = async io => {
await io.save<string[]>('/components');
await io.save<string[]>('/runs');
};
export default worker;
export default {
test: [
'input_reshape/input/audio/7',
'input_reshape/input/audio/4',
'input_reshape/input/audio/5',
'hahaha/input/audio/2',
'hahaha/input/audio/3',
'hahaha/input/audio/0',
'ohehe/input/audio/1',
'😼/input/audio/8',
'😼/input/audio/9'
],
train: [
'input_reshape/input/audio/6',
'input_reshape/input/audio/7',
'input_reshape/input/audio/4',
'input_reshape/input/audio/5',
'hahaha/input/audio/2',
'hahaha/input/audio/3',
'oheihei/input/audio/0',
'oheihei/input/audio/1',
'😼/input/audio/8',
'😼/input/audio/9'
runs: ['train', 'test'],
tags: [
[
'input_reshape/input/audio/7',
'input_reshape/input/audio/4',
'input_reshape/input/audio/5',
'hahaha/input/audio/2',
'hahaha/input/audio/3',
'hahaha/input/audio/0',
'ohehe/input/audio/1',
'😼/input/audio/8',
'😼/input/audio/9'
],
[
'input_reshape/input/audio/6',
'input_reshape/input/audio/7',
'input_reshape/input/audio/4',
'input_reshape/input/audio/5',
'hahaha/input/audio/2',
'hahaha/input/audio/3',
'oheihei/input/audio/0',
'oheihei/input/audio/1',
'😼/input/audio/8',
'😼/input/audio/9'
]
]
};
export default {
test: ['layer2/biases/summaries/mean', 'test/1234', 'another'],
train: [
'layer2/biases/summaries/mean',
'layer2/biases/summaries/accuracy',
'layer2/biases/summaries/cost',
'test/431',
'others'
runs: ['train', 'test'],
tags: [
['layer2/biases/summaries/mean', 'test/1234', 'another'],
[
'layer2/biases/summaries/mean',
'layer2/biases/summaries/accuracy',
'layer2/biases/summaries/cost',
'test/431',
'others'
]
]
};
export default {
test: ['layer2/biases/summaries/mean'],
train: ['layer2/biases/summaries/mean', 'layer2/biases/summaries/accuracy', 'layer2/biases/summaries/cost']
runs: ['train', 'test'],
tags: [
['layer2/biases/summaries/mean'],
['layer2/biases/summaries/mean', 'layer2/biases/summaries/accuracy', 'layer2/biases/summaries/cost']
]
};
export default {
test: [
'input_reshape/input/image/7',
'input_reshape/input/image/4',
'input_reshape/input/image/5',
'hahaha/input/image/2',
'hahaha/input/image/3',
'hahaha/input/image/0',
'ohehe/input/image/1',
'😼/input/image/8',
'😼/input/image/9'
],
train: [
'input_reshape/input/image/6',
'input_reshape/input/image/7',
'input_reshape/input/image/4',
'input_reshape/input/image/5',
'hahaha/input/image/2',
'hahaha/input/image/3',
'oheihei/input/image/0',
'oheihei/input/image/1',
'😼/input/image/8',
'😼/input/image/9'
runs: ['train', 'test'],
tags: [
[
'input_reshape/input/image/7',
'input_reshape/input/image/4',
'input_reshape/input/image/5',
'hahaha/input/image/2',
'hahaha/input/image/3',
'hahaha/input/image/0',
'ohehe/input/image/1',
'😼/input/image/8',
'😼/input/image/9'
],
[
'input_reshape/input/image/6',
'input_reshape/input/image/7',
'input_reshape/input/image/4',
'input_reshape/input/image/5',
'hahaha/input/image/2',
'hahaha/input/image/3',
'oheihei/input/image/0',
'oheihei/input/image/1',
'😼/input/image/8',
'😼/input/image/9'
]
]
};
export default {
test: ['layer2/biases/summaries/mean', 'test/1234', 'another'],
train: [
'layer2/biases/summaries/mean',
'layer2/biases/summaries/accuracy',
'layer2/biases/summaries/cost',
'test/431',
'others'
runs: ['train', 'test'],
tags: [
['layer2/biases/summaries/mean', 'test/1234', 'another'],
[
'layer2/biases/summaries/mean',
'layer2/biases/summaries/accuracy',
'layer2/biases/summaries/cost',
'test/431',
'others'
]
]
};
export default {
test: ['layer2/biases/summaries/mean', 'test/1234', 'another'],
train: [
'layer2/biases/summaries/mean',
'layer2/biases/summaries/accuracy',
'layer2/biases/summaries/cost',
'test/431',
'others'
runs: ['train', 'test'],
tags: [
['layer2/biases/summaries/mean', 'test/1234', 'another'],
[
'layer2/biases/summaries/mean',
'layer2/biases/summaries/accuracy',
'layer2/biases/summaries/cost',
'test/431',
'others'
]
]
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册