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

add tag select in high-dimensional page (#629)

* feat: add tag select in high-dimensional page

* v2.0.0-beta.43
上级 e09ab3d2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"packages": [ "packages": [
"packages/*" "packages/*"
], ],
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"command": { "command": {
......
{ {
"name": "@visualdl/cli", "name": "@visualdl/cli",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
"visualdl", "visualdl",
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"dist" "dist"
], ],
"dependencies": { "dependencies": {
"@visualdl/server": "2.0.0-beta.42", "@visualdl/server": "2.0.0-beta.43",
"open": "7.0.3", "open": "7.0.3",
"ora": "4.0.4", "ora": "4.0.4",
"pm2": "4.4.0", "pm2": "4.4.0",
......
...@@ -47,6 +47,7 @@ type Data = { ...@@ -47,6 +47,7 @@ type Data = {
type HighDimensionalChartProps = { type HighDimensionalChartProps = {
run: string; run: string;
tag: string;
running?: boolean; running?: boolean;
labelVisibility?: boolean; labelVisibility?: boolean;
reduction: Reduction; reduction: Reduction;
...@@ -56,6 +57,7 @@ type HighDimensionalChartProps = { ...@@ -56,6 +57,7 @@ type HighDimensionalChartProps = {
const HighDimensionalChart: FunctionComponent<HighDimensionalChartProps> = ({ const HighDimensionalChart: FunctionComponent<HighDimensionalChartProps> = ({
run, run,
tag,
running, running,
labelVisibility, labelVisibility,
keyword, keyword,
...@@ -66,8 +68,9 @@ const HighDimensionalChart: FunctionComponent<HighDimensionalChartProps> = ({ ...@@ -66,8 +68,9 @@ const HighDimensionalChart: FunctionComponent<HighDimensionalChartProps> = ({
const {data, error, loading} = useRunningRequest<Data>( const {data, error, loading} = useRunningRequest<Data>(
`/embeddings/embedding?${queryString.stringify({ `/embeddings/embedding?${queryString.stringify({
run: run ?? '', run,
dimension: Number.parseInt(dimension), tag,
dimension: Number.parseInt(dimension, 10),
reduction reduction
})}`, })}`,
!!running !!running
......
{ {
"name": "@visualdl/core", "name": "@visualdl/core",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"title": "VisualDL", "title": "VisualDL",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
"test": "echo \"Error: no test specified\" && exit 0" "test": "echo \"Error: no test specified\" && exit 0"
}, },
"dependencies": { "dependencies": {
"@visualdl/i18n": "2.0.0-beta.42", "@visualdl/i18n": "2.0.0-beta.43",
"@visualdl/wasm": "2.0.0-beta.42", "@visualdl/wasm": "2.0.0-beta.43",
"bignumber.js": "9.0.0", "bignumber.js": "9.0.0",
"dagre-d3": "0.6.4", "dagre-d3": "0.6.4",
"echarts": "4.7.0", "echarts": "4.7.0",
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
"@types/react": "16.9.34", "@types/react": "16.9.34",
"@types/react-dom": "16.9.7", "@types/react-dom": "16.9.7",
"@types/styled-components": "5.1.0", "@types/styled-components": "5.1.0",
"@visualdl/mock": "2.0.0-beta.42", "@visualdl/mock": "2.0.0-beta.43",
"babel-plugin-emotion": "10.0.33", "babel-plugin-emotion": "10.0.33",
"babel-plugin-styled-components": "1.10.7", "babel-plugin-styled-components": "1.10.7",
"babel-plugin-typescript-to-proptypes": "1.3.2", "babel-plugin-typescript-to-proptypes": "1.3.2",
......
import {Dimension, Reduction} from '~/resource/high-dimensional'; import {Dimension, Reduction} from '~/resource/high-dimensional';
import {NextI18NextPage, useTranslation} from '~/utils/i18n'; import {NextI18NextPage, useTranslation} from '~/utils/i18n';
import React, {useEffect, useState} from 'react'; import React, {useEffect, useMemo, useState} from 'react';
import Select, {SelectProps} from '~/components/Select'; import Select, {SelectProps} from '~/components/Select';
import {em, rem} from '~/utils/style'; import {em, rem} from '~/utils/style';
...@@ -44,18 +44,51 @@ const AsideTitle = styled.div` ...@@ -44,18 +44,51 @@ const AsideTitle = styled.div`
margin-bottom: ${rem(10)}; margin-bottom: ${rem(10)};
`; `;
type Item = {
run: string;
tag: string;
label: string;
};
const HighDimensional: NextI18NextPage = () => { const HighDimensional: NextI18NextPage = () => {
const {t} = useTranslation(['high-dimensional', 'common']); const {t} = useTranslation(['high-dimensional', 'common']);
const [running, setRunning] = useState(true); 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[]>>(
'/embeddings/tags',
running
);
const error = useMemo(() => runsError || tagsError, [runsError, tagsError]);
const loading = useMemo(() => runsLoading || tagsLoading, [runsLoading, tagsLoading]);
const list = useMemo(() => {
if (!runs || !tags) {
return [];
}
return runs.reduce<Item[]>(
(p, run) => [...p, ...(tags[run].map(tag => ({run, tag, label: `${run}/${tag}`})) ?? [])],
[]
);
}, [runs, tags]);
const labelList = useMemo(() => list.map(item => item.label), [list]);
const {query} = useRouter(); const {query} = useRouter();
const queryRun = Array.isArray(query.run) ? query.run[0] : query.run; const selectedLabel = useMemo(() => {
const {data: runs, error, loading} = useRunningRequest<string[]>('/runs', running); const run = Array.isArray(query.run) ? query.run[0] : query.run;
const selectedRun = queryRun && runs?.includes(queryRun) ? queryRun : runs?.[0]; return (run && list.find(item => item.run === run)?.label) ?? list[0]?.label;
}, [query.run, list]);
const [label, setLabel] = useState(selectedLabel);
useEffect(() => setLabel(selectedLabel), [selectedLabel]);
const [run, setRun] = useState(selectedRun); const selectedItem = useMemo(() => list.find(item => item.label === label) ?? {run: '', tag: '', label: ''}, [
useEffect(() => setRun(selectedRun), [setRun, selectedRun]); list,
label
]);
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const debounceSearch = useSearchValue(search); const debounceSearch = useSearchValue(search);
...@@ -66,11 +99,7 @@ const HighDimensional: NextI18NextPage = () => { ...@@ -66,11 +99,7 @@ const HighDimensional: NextI18NextPage = () => {
const aside = ( const aside = (
<AsideSection> <AsideSection>
<AsideTitle>{t('common:select-runs')}</AsideTitle> <AsideTitle>{t('common:select-runs')}</AsideTitle>
<StyledSelect <StyledSelect list={labelList} value={label} onChange={setLabel} />
list={runs}
value={run}
onChange={(value: NonNullable<typeof runs>[number]) => setRun(value)}
/>
<AsideDivider /> <AsideDivider />
<Field> <Field>
<SearchInput placeholder={t('common:search')} value={search} onChange={setSearch} /> <SearchInput placeholder={t('common:search')} value={search} onChange={setSearch} />
...@@ -123,7 +152,8 @@ const HighDimensional: NextI18NextPage = () => { ...@@ -123,7 +152,8 @@ const HighDimensional: NextI18NextPage = () => {
<HighDimensionalChart <HighDimensionalChart
dimension={dimension} dimension={dimension}
keyword={debounceSearch} keyword={debounceSearch}
run={run ?? ''} run={selectedItem.run}
tag={selectedItem.tag}
running={running} running={running}
labelVisibility={labelVisibility} labelVisibility={labelVisibility}
reduction={reduction} reduction={reduction}
......
{ {
"name": "@visualdl/i18n", "name": "@visualdl/i18n",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
"visualdl", "visualdl",
......
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'
]
};
{ {
"name": "@visualdl/mock", "name": "@visualdl/mock",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
"visualdl", "visualdl",
......
{ {
"name": "@visualdl/server", "name": "@visualdl/server",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
"visualdl", "visualdl",
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
"ecosystem.config.d.ts" "ecosystem.config.d.ts"
], ],
"dependencies": { "dependencies": {
"@visualdl/core": "2.0.0-beta.42", "@visualdl/core": "2.0.0-beta.43",
"@visualdl/i18n": "2.0.0-beta.42", "@visualdl/i18n": "2.0.0-beta.43",
"express": "4.17.1", "express": "4.17.1",
"http-proxy-middleware": "1.0.3", "http-proxy-middleware": "1.0.3",
"next": "9.3.6", "next": "9.3.6",
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
"@types/shelljs": "0.8.7", "@types/shelljs": "0.8.7",
"@types/webpack": "4.41.12", "@types/webpack": "4.41.12",
"@types/webpack-dev-middleware": "3.7.0", "@types/webpack-dev-middleware": "3.7.0",
"@visualdl/mock": "2.0.0-beta.42", "@visualdl/mock": "2.0.0-beta.43",
"cross-env": "7.0.2", "cross-env": "7.0.2",
"nodemon": "2.0.3", "nodemon": "2.0.3",
"shelljs": "0.8.4", "shelljs": "0.8.4",
......
{ {
"name": "@visualdl/serverless", "name": "@visualdl/serverless",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
"visualdl", "visualdl",
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"devDependencies": { "devDependencies": {
"@types/node": "13.13.5", "@types/node": "13.13.5",
"@types/rimraf": "3.0.0", "@types/rimraf": "3.0.0",
"@visualdl/core": "2.0.0-beta.42", "@visualdl/core": "2.0.0-beta.43",
"cross-env": "7.0.2", "cross-env": "7.0.2",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"ts-node": "8.10.1", "ts-node": "8.10.1",
......
{ {
"name": "@visualdl/wasm", "name": "@visualdl/wasm",
"version": "2.0.0-beta.42", "version": "2.0.0-beta.43",
"title": "VisualDL", "title": "VisualDL",
"description": "A platform to visualize the deep learning process and result.", "description": "A platform to visualize the deep learning process and result.",
"keywords": [ "keywords": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册