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