Skip to content

Commit 9553ec7

Browse files
authored
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
1 parent fd51dd8 commit 9553ec7

26 files changed

Lines changed: 73 additions & 40 deletions

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ repos:
1717
- id: flake8
1818
alias: be
1919
exclude: ^frontend/
20+
- repo: https://github.com/shellcheck-py/shellcheck-py
21+
rev: v0.7.1.1
22+
hooks:
23+
- id: shellcheck
2024
- repo: local
2125
hooks:
2226
- id: fe

frontend/lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "2.1.1",
5+
"version": "2.1.4",
66
"npmClient": "yarn",
77
"useWorkspaces": true,
88
"command": {

frontend/packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@visualdl/cli",
3-
"version": "2.1.1",
3+
"version": "2.1.4",
44
"description": "A platform to visualize the deep learning process and result.",
55
"keywords": [
66
"visualdl",
@@ -34,7 +34,7 @@
3434
"dist"
3535
],
3636
"dependencies": {
37-
"@visualdl/server": "2.1.1",
37+
"@visualdl/server": "2.1.4",
3838
"open": "7.3.0",
3939
"ora": "5.1.0",
4040
"pm2": "4.5.1",

frontend/packages/core/builder/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ process.env.SNOWPACK_PUBLIC_PATH = process.env.CDN_VERSION
2323
? ''
2424
: process.env.PUBLIC_PATH;
2525

26-
// BASE_URI is for env and router, must be local address which starts with a `/` or empty string
26+
// BASE_URI is for env, router and workers. Must be local address which starts with a `/` or empty string
2727
// if it is not set and PUBLIC_PATH is not a CDN address, it will be set to the same value of PUBLIC_PATH
2828
process.env.SNOWPACK_PUBLIC_BASE_URI =
2929
process.env.SNOWPACK_PUBLIC_PATH.startsWith('/') || process.env.PUBLIC_PATH === ''

frontend/packages/core/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@visualdl/core",
3-
"version": "2.1.1",
3+
"version": "2.1.4",
44
"description": "A platform to visualize the deep learning process and result.",
55
"keywords": [
66
"visualdl",
@@ -35,8 +35,8 @@
3535
],
3636
"dependencies": {
3737
"@tippyjs/react": "4.2.0",
38-
"@visualdl/netron": "2.1.1",
39-
"@visualdl/wasm": "2.1.1",
38+
"@visualdl/netron": "2.1.4",
39+
"@visualdl/wasm": "2.1.4",
4040
"bignumber.js": "9.0.1",
4141
"d3": "6.3.1",
4242
"d3-format": "2.0.0",
@@ -105,7 +105,7 @@
105105
"@types/react-router-dom": "5.1.6",
106106
"@types/snowpack-env": "2.3.3",
107107
"@types/styled-components": "5.1.7",
108-
"@visualdl/mock": "2.1.1",
108+
"@visualdl/mock": "2.1.4",
109109
"babel-plugin-styled-components": "1.12.0",
110110
"dotenv": "8.2.0",
111111
"enhanced-resolve": "5.4.1",

frontend/packages/core/src/hooks/useWorker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {useEffect, useState} from 'react';
1919
import type {InitializeData} from '~/worker';
2020
import {WebWorker} from '~/worker';
2121

22-
const PUBLIC_PATH: string = import.meta.env.SNOWPACK_PUBLIC_PATH;
22+
const BASE_URI: string = import.meta.env.SNOWPACK_PUBLIC_BASE_URI;
2323

2424
type WorkerResult<D, E extends Error> = {
2525
data?: D;
@@ -31,7 +31,7 @@ const useWorker = <D, P = unknown, E extends Error = Error>(name: string, params
3131
const [result, setResult] = useState<WorkerResult<D, E>>({});
3232

3333
useEffect(() => {
34-
const worker = new WebWorker(`${PUBLIC_PATH}/_dist_/worker/${name}.js`, {type: 'module'});
34+
const worker = new WebWorker(`${BASE_URI}/_dist_/worker/${name}.js`, {type: 'module'});
3535
worker.emit<InitializeData>('INITIALIZE', {env: import.meta.env});
3636
worker.on('INITIALIZED', () => {
3737
setResult({worker});

frontend/packages/demo/builder/high-dimensional.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
import type {Worker} from './types';
17+
import type {Embedding, Worker} from './types';
1818

1919
const worker: Worker = async io => {
2020
const components = await io.getData<string[]>('/components');
2121
if (!components.includes('embeddings')) {
2222
return;
2323
}
2424

25-
// await io.save<Record<string, string[]>>('/embedding/embedding');
25+
const list = await io.save<Embedding[]>('/embedding/list');
26+
await Promise.all(
27+
list.map(({name}) =>
28+
Promise.all([io.saveBinary('/embedding/tensor', {name}), io.saveBinary('/embedding/metadata', {name})])
29+
)
30+
);
2631
};
2732

2833
export default worker;

frontend/packages/demo/builder/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
/* eslint-disable no-console */
1818

1919
import IO from './io';
20-
import {SIGINT} from 'constants';
2120
import type {Worker} from './types';
2221
import getPort from 'get-port';
2322
import mkdirp from 'mkdirp';
@@ -63,7 +62,7 @@ async function start() {
6362

6463
const stop = () => {
6564
if (!p.killed) {
66-
p.kill(SIGINT);
65+
p.kill('SIGINT');
6766
}
6867
};
6968

frontend/packages/demo/builder/io.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export default class IO {
174174

175175
const response = await this.fetch(uri, query);
176176
if (!response.ok) {
177-
throw new Error('not ok');
177+
throw new Error(`not ok: ${uri}`);
178178
}
179179

180180
let content: ResponseData<T> | ArrayBuffer;

frontend/packages/demo/builder/scalar.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import type {Data, Worker} from './types';
1818

19+
const DataTypes = ['csv', 'tsv'];
20+
1921
const worker: Worker = async io => {
2022
const components = await io.getData<string[]>('/components');
2123
if (!components.includes('scalar')) {
@@ -26,7 +28,10 @@ const worker: Worker = async io => {
2628
const q = [];
2729
for (const [index, run] of runs.entries()) {
2830
for (const tag of tags[index]) {
29-
q.push(io.save('/scalar/list', {run, tag}));
31+
q.push(
32+
io.save('/scalar/list', {run, tag}),
33+
...DataTypes.map(type => io.saveBinary('/scalar/data', {run, tag, type}))
34+
);
3035
}
3136
}
3237
await Promise.all(q);

0 commit comments

Comments
 (0)