Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
NAS visualization (#2085)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultmaster authored Mar 3, 2020
1 parent ede5938 commit 9987014
Show file tree
Hide file tree
Showing 21 changed files with 12,767 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ build:
cp -rf src/nni_manager/config src/nni_manager/dist/
#$(_INFO) Building WebUI $(_END)
cd src/webui && $(NNI_YARN) && $(NNI_YARN) build
#$(_INFO) Building NAS UI $(_END)
cd src/nasui && $(NNI_YARN) && $(NNI_YARN) build

# All-in-one target for non-expert users
# Installs NNI as well as its dependencies, and update bashrc to set PATH
Expand Down
23 changes: 23 additions & 0 deletions src/nasui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
52 changes: 52 additions & 0 deletions src/nasui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "nasnni-vis-ts",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.9.3",
"@material-ui/icons": "^4.9.1",
"cytoscape": "^3.14.0",
"cytoscape-dagre": "^2.2.2",
"cytoscape-panzoom": "^2.5.3",
"express": "^4.17.1",
"lodash": "^4.17.15",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.4.0",
"typeface-roboto": "^0.0.75",
"typescript": "~3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"backend": "node server.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/cytoscape": "^3.14.0",
"@types/jest": "^24.0.0",
"@types/lodash": "^4.14.149",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0"
},
"proxy": "http://localhost:8080"
}
Binary file added src/nasui/public/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/nasui/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>NNI NAS Board</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
27 changes: 27 additions & 0 deletions src/nasui/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const express = require('express');
const path = require('path');
const fs = require('fs');
const app = express();
const argv = require('minimist')(process.argv.slice(2));
const port = argv.port || 8080;
const logdir = argv.logdir || './mockdata';

app.use(express.static(path.join(__dirname, 'build')));
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.get('/refresh', (req, res) => {
const graph = fs.readFileSync(path.join(logdir, 'graph.json'), 'utf8');
const log = fs.readFileSync(path.join(logdir, 'log'), 'utf-8')
.split('\n')
.filter(Boolean)
.map(JSON.parse);
res.send({
'graph': JSON.parse(graph),
'log': log,
});
});

app.listen(port, '0.0.0.0', () => {
console.log(`NNI NAS board is running on port ${port}, logdir is ${logdir}.`);
});
38 changes: 38 additions & 0 deletions src/nasui/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
svg {
overflow: hidden;
}

.node {
white-space: nowrap;
}

.node.input rect, .node.output rect {
fill: #9d0f0f;
}

.node.hub rect {
fill: #0f309d;
}

.node.blob rect {
fill: #0F9D58;
}

.node text {
fill: #fff;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-weight: 500;
}

.cluster rect {
stroke: #333;
fill: #000;
fill-opacity: 0.1;
stroke-width: 1.5px;
}

.edgePath path.path {
stroke: #333;
stroke-width: 1.5px;
fill: none;
}
Loading

0 comments on commit 9987014

Please sign in to comment.