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

update demo (#899)

* docs: update demo

* publish fe@2.1.2

* chore: remove deprecated constants

* publish fe@2.1.3

* fix: fix web worker cross origin

* publish fe@2.1.4

* style: lint shell scripts
上级 fd51dd88
...@@ -17,6 +17,10 @@ repos: ...@@ -17,6 +17,10 @@ repos:
- id: flake8 - id: flake8
alias: be alias: be
exclude: ^frontend/ exclude: ^frontend/
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.7.1.1
hooks:
- id: shellcheck
- repo: local - repo: local
hooks: hooks:
- id: fe - id: fe
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"packages": [ "packages": [
"packages/*" "packages/*"
], ],
"version": "2.1.1", "version": "2.1.4",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"command": { "command": {
......
{ {
"name": "@visualdl/cli", "name": "@visualdl/cli",
"version": "2.1.1", "version": "2.1.4",
"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.1.1", "@visualdl/server": "2.1.4",
"open": "7.3.0", "open": "7.3.0",
"ora": "5.1.0", "ora": "5.1.0",
"pm2": "4.5.1", "pm2": "4.5.1",
......
...@@ -23,7 +23,7 @@ process.env.SNOWPACK_PUBLIC_PATH = process.env.CDN_VERSION ...@@ -23,7 +23,7 @@ process.env.SNOWPACK_PUBLIC_PATH = process.env.CDN_VERSION
? '' ? ''
: process.env.PUBLIC_PATH; : process.env.PUBLIC_PATH;
// BASE_URI is for env and router, must be local address which starts with a `/` or empty string // BASE_URI is for env, router and workers. Must be local address which starts with a `/` or empty string
// if it is not set and PUBLIC_PATH is not a CDN address, it will be set to the same value of PUBLIC_PATH // if it is not set and PUBLIC_PATH is not a CDN address, it will be set to the same value of PUBLIC_PATH
process.env.SNOWPACK_PUBLIC_BASE_URI = process.env.SNOWPACK_PUBLIC_BASE_URI =
process.env.SNOWPACK_PUBLIC_PATH.startsWith('/') || process.env.PUBLIC_PATH === '' process.env.SNOWPACK_PUBLIC_PATH.startsWith('/') || process.env.PUBLIC_PATH === ''
......
{ {
"name": "@visualdl/core", "name": "@visualdl/core",
"version": "2.1.1", "version": "2.1.4",
"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",
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
], ],
"dependencies": { "dependencies": {
"@tippyjs/react": "4.2.0", "@tippyjs/react": "4.2.0",
"@visualdl/netron": "2.1.1", "@visualdl/netron": "2.1.4",
"@visualdl/wasm": "2.1.1", "@visualdl/wasm": "2.1.4",
"bignumber.js": "9.0.1", "bignumber.js": "9.0.1",
"d3": "6.3.1", "d3": "6.3.1",
"d3-format": "2.0.0", "d3-format": "2.0.0",
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
"@types/react-router-dom": "5.1.6", "@types/react-router-dom": "5.1.6",
"@types/snowpack-env": "2.3.3", "@types/snowpack-env": "2.3.3",
"@types/styled-components": "5.1.7", "@types/styled-components": "5.1.7",
"@visualdl/mock": "2.1.1", "@visualdl/mock": "2.1.4",
"babel-plugin-styled-components": "1.12.0", "babel-plugin-styled-components": "1.12.0",
"dotenv": "8.2.0", "dotenv": "8.2.0",
"enhanced-resolve": "5.4.1", "enhanced-resolve": "5.4.1",
......
...@@ -19,7 +19,7 @@ import {useEffect, useState} from 'react'; ...@@ -19,7 +19,7 @@ import {useEffect, useState} from 'react';
import type {InitializeData} from '~/worker'; import type {InitializeData} from '~/worker';
import {WebWorker} from '~/worker'; import {WebWorker} from '~/worker';
const PUBLIC_PATH: string = import.meta.env.SNOWPACK_PUBLIC_PATH; const BASE_URI: string = import.meta.env.SNOWPACK_PUBLIC_BASE_URI;
type WorkerResult<D, E extends Error> = { type WorkerResult<D, E extends Error> = {
data?: D; data?: D;
...@@ -31,7 +31,7 @@ const useWorker = <D, P = unknown, E extends Error = Error>(name: string, params ...@@ -31,7 +31,7 @@ const useWorker = <D, P = unknown, E extends Error = Error>(name: string, params
const [result, setResult] = useState<WorkerResult<D, E>>({}); const [result, setResult] = useState<WorkerResult<D, E>>({});
useEffect(() => { useEffect(() => {
const worker = new WebWorker(`${PUBLIC_PATH}/_dist_/worker/${name}.js`, {type: 'module'}); const worker = new WebWorker(`${BASE_URI}/_dist_/worker/${name}.js`, {type: 'module'});
worker.emit<InitializeData>('INITIALIZE', {env: import.meta.env}); worker.emit<InitializeData>('INITIALIZE', {env: import.meta.env});
worker.on('INITIALIZED', () => { worker.on('INITIALIZED', () => {
setResult({worker}); setResult({worker});
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import type {Worker} from './types'; import type {Embedding, Worker} from './types';
const worker: Worker = async io => { const worker: Worker = async io => {
const components = await io.getData<string[]>('/components'); const components = await io.getData<string[]>('/components');
...@@ -22,7 +22,12 @@ const worker: Worker = async io => { ...@@ -22,7 +22,12 @@ const worker: Worker = async io => {
return; return;
} }
// await io.save<Record<string, string[]>>('/embedding/embedding'); const list = await io.save<Embedding[]>('/embedding/list');
await Promise.all(
list.map(({name}) =>
Promise.all([io.saveBinary('/embedding/tensor', {name}), io.saveBinary('/embedding/metadata', {name})])
)
);
}; };
export default worker; export default worker;
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import IO from './io'; import IO from './io';
import {SIGINT} from 'constants';
import type {Worker} from './types'; import type {Worker} from './types';
import getPort from 'get-port'; import getPort from 'get-port';
import mkdirp from 'mkdirp'; import mkdirp from 'mkdirp';
...@@ -63,7 +62,7 @@ async function start() { ...@@ -63,7 +62,7 @@ async function start() {
const stop = () => { const stop = () => {
if (!p.killed) { if (!p.killed) {
p.kill(SIGINT); p.kill('SIGINT');
} }
}; };
......
...@@ -174,7 +174,7 @@ export default class IO { ...@@ -174,7 +174,7 @@ export default class IO {
const response = await this.fetch(uri, query); const response = await this.fetch(uri, query);
if (!response.ok) { if (!response.ok) {
throw new Error('not ok'); throw new Error(`not ok: ${uri}`);
} }
let content: ResponseData<T> | ArrayBuffer; let content: ResponseData<T> | ArrayBuffer;
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
import type {Data, Worker} from './types'; import type {Data, Worker} from './types';
const DataTypes = ['csv', 'tsv'];
const worker: Worker = async io => { const worker: Worker = async io => {
const components = await io.getData<string[]>('/components'); const components = await io.getData<string[]>('/components');
if (!components.includes('scalar')) { if (!components.includes('scalar')) {
...@@ -26,7 +28,10 @@ const worker: Worker = async io => { ...@@ -26,7 +28,10 @@ const worker: Worker = async io => {
const q = []; const q = [];
for (const [index, run] of runs.entries()) { for (const [index, run] of runs.entries()) {
for (const tag of tags[index]) { for (const tag of tags[index]) {
q.push(io.save('/scalar/list', {run, tag})); q.push(
io.save('/scalar/list', {run, tag}),
...DataTypes.map(type => io.saveBinary('/scalar/data', {run, tag, type}))
);
} }
} }
await Promise.all(q); await Promise.all(q);
......
...@@ -22,3 +22,9 @@ export type Data = { ...@@ -22,3 +22,9 @@ export type Data = {
runs: string[]; runs: string[];
tags: string[][]; tags: string[][];
}; };
export type Embedding = {
name: string;
shape: [number, number];
path: string;
};
{ {
"name": "@visualdl/demo", "name": "@visualdl/demo",
"version": "2.1.1", "version": "2.1.4",
"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/mock", "name": "@visualdl/mock",
"version": "2.1.1", "version": "2.1.4",
"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/netron", "name": "@visualdl/netron",
"version": "2.1.1", "version": "2.1.4",
"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.1.1", "version": "2.1.4",
"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",
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"dev": "cross-env NODE_ENV=development nodemon --watch index.ts --exec \"ts-node index.ts\"", "dev": "cross-env NODE_ENV=development nodemon --watch index.ts --exec \"ts-node index.ts\"",
"dev:demo": "cross-env DEMO=1 yarn dev",
"start": "pm2-runtime ecosystem.config.js", "start": "pm2-runtime ecosystem.config.js",
"test": "echo \"Error: no test specified\" && exit 0" "test": "echo \"Error: no test specified\" && exit 0"
}, },
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
"ecosystem.config.d.ts" "ecosystem.config.d.ts"
], ],
"dependencies": { "dependencies": {
"@visualdl/core": "2.1.1", "@visualdl/core": "2.1.4",
"dotenv": "8.2.0", "dotenv": "8.2.0",
"enhanced-resolve": "5.4.1", "enhanced-resolve": "5.4.1",
"express": "4.17.1", "express": "4.17.1",
...@@ -47,14 +48,14 @@ ...@@ -47,14 +48,14 @@
"@types/enhanced-resolve": "3.0.6", "@types/enhanced-resolve": "3.0.6",
"@types/express": "4.17.9", "@types/express": "4.17.9",
"@types/node": "14.14.16", "@types/node": "14.14.16",
"@visualdl/mock": "2.1.1", "@visualdl/mock": "2.1.4",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"nodemon": "2.0.6", "nodemon": "2.0.6",
"ts-node": "9.1.1", "ts-node": "9.1.1",
"typescript": "4.0.5" "typescript": "4.0.5"
}, },
"optionalDependencies": { "optionalDependencies": {
"@visualdl/demo": "2.1.1" "@visualdl/demo": "2.1.4"
}, },
"engines": { "engines": {
"node": ">=12", "node": ">=12",
......
{ {
"name": "@visualdl/wasm", "name": "@visualdl/wasm",
"version": "2.1.1", "version": "2.1.4",
"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": [
......
...@@ -11,6 +11,7 @@ OUTPUT="output" ...@@ -11,6 +11,7 @@ OUTPUT="output"
OUTPUT_PATH="$WORKING_PATH/$OUTPUT" OUTPUT_PATH="$WORKING_PATH/$OUTPUT"
if [ -f "$HOME/.cargo/env" ]; then if [ -f "$HOME/.cargo/env" ]; then
# shellcheck source=/dev/null
source "$HOME/.cargo/env" source "$HOME/.cargo/env"
fi fi
......
...@@ -4,7 +4,7 @@ set -e ...@@ -4,7 +4,7 @@ set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/.. cd "${SCRIPT_DIR}/.."
# rust toolchain # rust toolchain
# https://rustup.rs/ # https://rustup.rs/
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
set -e set -e
echo $0
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/.. cd "${SCRIPT_DIR}/.."
./node_modules/.bin/lint-staged --no-stash ./node_modules/.bin/lint-staged --no-stash
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PACKAGES="${SCRIPT_DIR}/../packages"
for dirname in "${PACKAGES}"/*; do
package="${PACKAGES}/${dirname}"
if [ -d "$package" ]; then
(cd "$package" && npm publish)
fi
done
...@@ -11,6 +11,7 @@ build_frontend() { ...@@ -11,6 +11,7 @@ build_frontend() {
mkdir -p "$FRONTEND_DIST" mkdir -p "$FRONTEND_DIST"
cd "$FRONTEND_DIR" cd "$FRONTEND_DIR"
# shellcheck disable=SC1091
. ./scripts/install.sh . ./scripts/install.sh
SCOPE="serverless" \ SCOPE="serverless" \
PUBLIC_PATH="{{PUBLIC_PATH}}" \ PUBLIC_PATH="{{PUBLIC_PATH}}" \
......
...@@ -3,22 +3,20 @@ set -e ...@@ -3,22 +3,20 @@ set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/.. cd "${SCRIPT_DIR}/.."
which python > /dev/null 2>&1 if which python > /dev/null 2>&1; then
if [ $? -ne 0 ]; then
echo "You need to install Python 3.5+" echo "You need to install Python 3.5+"
exit 1 exit 1
fi fi
python --version python --version
which node > /dev/null 2>&1 if which node > /dev/null 2>&1; then
if [ $? -ne 0 ]; then
echo "You need to install nodejs 14+" echo "You need to install nodejs 14+"
exit 1 exit 1
fi fi
node --version node --version
pip install pre-commit && pre-commit install
pip install --disable-pip-version-check -r requirements.txt pip install --disable-pip-version-check -r requirements.txt
(cd frontend && scripts/install.sh) (cd frontend && scripts/install.sh)
pre-commit install
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册