From 93df53a2c34d656a5fad5235c2b84fe964cb4108 Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 16:15:59 +0800 Subject: [PATCH 01/36] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experiment}/components/StatusLabel.vue | 0 .../experiment/pages/chart/ChartPage.vue | 16 +-- .../pages/chart/components/G2Chart.vue | 6 +- .../pages/chart/components/PlotlyChart.vue | 98 ------------------- 4 files changed, 14 insertions(+), 106 deletions(-) rename vue/src/{ => views/experiment}/components/StatusLabel.vue (100%) delete mode 100644 vue/src/views/experiment/pages/chart/components/PlotlyChart.vue diff --git a/vue/src/components/StatusLabel.vue b/vue/src/views/experiment/components/StatusLabel.vue similarity index 100% rename from vue/src/components/StatusLabel.vue rename to vue/src/views/experiment/components/StatusLabel.vue diff --git a/vue/src/views/experiment/pages/chart/ChartPage.vue b/vue/src/views/experiment/pages/chart/ChartPage.vue index 12633b83..23816247 100644 --- a/vue/src/views/experiment/pages/chart/ChartPage.vue +++ b/vue/src/views/experiment/pages/chart/ChartPage.vue @@ -2,7 +2,7 @@
-

{{ projectStore.name + '/' + experiment.name }}

+

{{ experiment.name }}

- + @@ -24,15 +24,12 @@ **/ import { inject, ref, provide } from 'vue' import { onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router' -import { useProjectStore } from '@swanlab-vue/store' import SLIcon from '@swanlab-vue/components/SLIcon.vue' -import StatusLabel from '@swanlab-vue/components/StatusLabel.vue' +import StatusLabel from '@swanlab-vue/views/experiment/components/StatusLabel.vue' import ChartsContainer from './components/ChartsContainer.vue' import G2Chart from './components/G2Chart.vue' import http from '@swanlab-vue/api/http' -const projectStore = useProjectStore() - const experiment = inject('experiment') const experimentId = inject('experimentId') @@ -68,7 +65,7 @@ const getExperiment = (id = experimentId.value) => { http.get('/experiment/' + id).then(({ data }) => { // 判断data.tags和tags是否相同,如果不同,重新渲染 if (data.tags.join('') !== tags.value?.join('')) { - console.log('不同,重新渲染', data.tags, tags.value) + // console.log('不同,重新渲染', data.tags, tags.value) tags.value = data.tags } // 如果status为0,且timer为undefined,开启轮询 @@ -85,6 +82,11 @@ const getExperiment = (id = experimentId.value) => { } // 立即执行 getExperiment() + +// ---------------------------------- 判断某个namespcace下是否存在图表 ---------------------------------- +const showContainer = (sources) => { + return !!sources?.length +} diff --git a/vue/src/views/experiment/pages/chart/components/G2Chart.vue b/vue/src/views/experiment/pages/chart/components/G2Chart.vue index 491dc05c..cb979354 100644 --- a/vue/src/views/experiment/pages/chart/components/G2Chart.vue +++ b/vue/src/views/experiment/pages/chart/components/G2Chart.vue @@ -62,13 +62,17 @@ let chart // type: 'timeCat', tickCount: 5 // 设置坐标轴刻度数量,防止数据过多导致刻度过密 }, + yAxis: {}, // 大小相关 height: 200, autoFit: true, + // 开启一些交互 + interactions: [{ type: 'brush-x' }], // 样式相关 - smooth: true, // 平滑曲线 + // smooth: true, // 平滑曲线 color: experimentColor.value }) + chart.render() // 启动轮询函数, startPolling() diff --git a/vue/src/views/experiment/pages/chart/components/PlotlyChart.vue b/vue/src/views/experiment/pages/chart/components/PlotlyChart.vue deleted file mode 100644 index 3f62b2a5..00000000 --- a/vue/src/views/experiment/pages/chart/components/PlotlyChart.vue +++ /dev/null @@ -1,98 +0,0 @@ - - - - - From a836c369487f8dd43f67c57fddc519e59cee11d0 Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 16:19:31 +0800 Subject: [PATCH 02/36] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StatusLabel.vue => components/SLStatusLabel.vue} | 0 vue/src/views/experiment/pages/chart/ChartPage.vue | 4 ++-- vue/src/views/home/HomeView.vue | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename vue/src/{views/experiment/components/StatusLabel.vue => components/SLStatusLabel.vue} (100%) diff --git a/vue/src/views/experiment/components/StatusLabel.vue b/vue/src/components/SLStatusLabel.vue similarity index 100% rename from vue/src/views/experiment/components/StatusLabel.vue rename to vue/src/components/SLStatusLabel.vue diff --git a/vue/src/views/experiment/pages/chart/ChartPage.vue b/vue/src/views/experiment/pages/chart/ChartPage.vue index 23816247..86f4fc85 100644 --- a/vue/src/views/experiment/pages/chart/ChartPage.vue +++ b/vue/src/views/experiment/pages/chart/ChartPage.vue @@ -3,7 +3,7 @@

{{ experiment.name }}

- - + {{ transTime(convertUtcToLocal(experiment.create_time)) }} @@ -52,7 +52,7 @@ import { useProjectStore } from '@swanlab-vue/store' import { formatTime } from '@swanlab-vue/utils/common' import { computed } from 'vue' -import StatusLabel from '@swanlab-vue/components/StatusLabel.vue' +import SLStatusLabel from '@swanlab-vue/components/SLStatusLabel.vue' import ExperimentName from './components/ExperimentName.vue' import { transTime, convertUtcToLocal } from '@swanlab-vue/utils/time' From be7d5023dbc08329bf2ec55aa8996d1e74b8577e Mon Sep 17 00:00:00 2001 From: Zirui Cai <1575079435@qq.com> Date: Mon, 11 Dec 2023 16:24:08 +0800 Subject: [PATCH 03/36] =?UTF-8?q?feat=EF=BC=9Aexperiment=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/i18n/zh-CN/experiment.json | 12 +++ vue/src/layouts/ExperimentLayout.vue | 2 +- vue/src/router/index.js | 2 +- .../pages/{ => index}/IndexPage.vue | 6 +- .../index/components/ExperimentHeader.vue | 90 +++++++++++++++++++ 5 files changed, 106 insertions(+), 6 deletions(-) rename vue/src/views/experiment/pages/{ => index}/IndexPage.vue (68%) create mode 100644 vue/src/views/experiment/pages/index/components/ExperimentHeader.vue diff --git a/vue/src/i18n/zh-CN/experiment.json b/vue/src/i18n/zh-CN/experiment.json index ed19145b..8288c94c 100644 --- a/vue/src/i18n/zh-CN/experiment.json +++ b/vue/src/i18n/zh-CN/experiment.json @@ -8,5 +8,17 @@ "-1": "停止", "0": "正在进行", "1": "完成" + }, + "header": { + "experiment_infos": { + "start_time": "开始时间", + "last_time": "持续时间", + "tags": "Tag" + }, + "experiment_device": { + "hostname": "Hostname", + "os": "操作系统", + "python": "Python版本" + } } } diff --git a/vue/src/layouts/ExperimentLayout.vue b/vue/src/layouts/ExperimentLayout.vue index 767bdf3b..377256a2 100644 --- a/vue/src/layouts/ExperimentLayout.vue +++ b/vue/src/layouts/ExperimentLayout.vue @@ -3,7 +3,7 @@
-
+
diff --git a/vue/src/router/index.js b/vue/src/router/index.js index ab4a763d..0afa4701 100644 --- a/vue/src/router/index.js +++ b/vue/src/router/index.js @@ -15,7 +15,7 @@ const routes = [ { path: 'index', name: 'experiment_index', - component: () => import('@swanlab-vue/views/experiment/pages/IndexPage.vue') + component: () => import('@swanlab-vue/views/experiment/pages/index/IndexPage.vue') }, { path: 'chart', diff --git a/vue/src/views/experiment/pages/IndexPage.vue b/vue/src/views/experiment/pages/index/IndexPage.vue similarity index 68% rename from vue/src/views/experiment/pages/IndexPage.vue rename to vue/src/views/experiment/pages/index/IndexPage.vue index 536159f3..c049c6fc 100644 --- a/vue/src/views/experiment/pages/IndexPage.vue +++ b/vue/src/views/experiment/pages/index/IndexPage.vue @@ -1,5 +1,5 @@ diff --git a/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue b/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue new file mode 100644 index 00000000..d07f5897 --- /dev/null +++ b/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue @@ -0,0 +1,90 @@ + + + + + From df3dbeb671aff62a118d887708831ae483f8882d Mon Sep 17 00:00:00 2001 From: Zirui Cai <1575079435@qq.com> Date: Mon, 11 Dec 2023 16:33:18 +0800 Subject: [PATCH 04/36] fix: status label --- .../experiment/pages/index/components/ExperimentHeader.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue b/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue index d07f5897..4ee1ed4a 100644 --- a/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue +++ b/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue @@ -3,7 +3,7 @@
{{ experiment.name }} - +
@@ -43,7 +43,7 @@ import { inject } from 'vue' **/ import { copyTextToClipboard } from '@swanlab-vue/utils/browser' import SLIcon from '@swanlab-vue/components/SLIcon.vue' -import StatusLabel from '@swanlab-vue/components/StatusLabel.vue' +import SLStatusLabel from '@swanlab-vue/components/SLStatusLabel.vue' import { computed } from 'vue' const experiment = inject('experiment') console.log(experiment.value) From 99a6e1c7de4129bbdd8461552a5fbb1b3f898f22 Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 17:06:11 +0800 Subject: [PATCH 05/36] header border --- .vscode/settings.json | 3 ++- .../views/experiment/components/TabsHeader.vue | 18 ++++++++++-------- .../views/experiment/pages/chart/ChartPage.vue | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5535501b..89e75a6d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,7 +10,8 @@ "store": "database", "help": "java", "experiment": "benchMark", - "chart": "app" + "chart": "app", + "index": "home" }, "material-icon-theme.files.associations": { ".env.mock": "Tune" diff --git a/vue/src/views/experiment/components/TabsHeader.vue b/vue/src/views/experiment/components/TabsHeader.vue index 3c2b6cf9..10efbc56 100644 --- a/vue/src/views/experiment/components/TabsHeader.vue +++ b/vue/src/views/experiment/components/TabsHeader.vue @@ -1,12 +1,6 @@ @@ -24,9 +25,9 @@ **/ import { inject, ref, provide } from 'vue' import { onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router' -import SLIcon from '@swanlab-vue/components/SLIcon.vue' import SLStatusLabel from '@swanlab-vue/components/SLStatusLabel.vue' import ChartsContainer from './components/ChartsContainer.vue' +import SLIcon from '@swanlab-vue/components/SLIcon.vue' import G2Chart from './components/G2Chart.vue' import http from '@swanlab-vue/api/http' From ec00f816d1f7f2fda8ac4e84e295031a394eb350 Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 17:47:34 +0800 Subject: [PATCH 06/36] fix #14 --- swanlab/database/__init__.py | 2 +- swanlab/server/router.py | 21 ++++++--------------- vue/src/components/HomeSiderBar.vue | 4 ++-- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/swanlab/database/__init__.py b/swanlab/database/__init__.py index a427e899..bd62cb1f 100644 --- a/swanlab/database/__init__.py +++ b/swanlab/database/__init__.py @@ -11,4 +11,4 @@ from .project import PT -print("swanlab.database init") +# print("swanlab.database init") diff --git a/swanlab/server/router.py b/swanlab/server/router.py index fe1b024e..3ad2b046 100644 --- a/swanlab/server/router.py +++ b/swanlab/server/router.py @@ -9,7 +9,7 @@ """ from fastapi import FastAPI -from fastapi.responses import HTMLResponse, FileResponse, RedirectResponse +from fastapi.responses import HTMLResponse, PlainTextResponse from fastapi.staticfiles import StaticFiles import time @@ -55,11 +55,13 @@ async def resp_static(request, call_next): if request.url.path.startswith(static_path): # 如果是请求静态资源,直接返回 return await call_next(request) - if request.url.path == "/": - return await call_next(request) if request.url.path.startswith("/api"): + # 如果是请求api,直接返回 return await call_next(request) - return RedirectResponse(url="/") + # 剩余情况返回index.html,交由前端路由处理 + with open(INDEX, "r", encoding="utf-8") as file: + html_content = file.read() + return HTMLResponse(content=html_content, status_code=200) # ---------------------------------- 在此处注册相关路由 ---------------------------------- @@ -71,18 +73,7 @@ async def resp_static(request, call_next): from .api.experiment import router as experiment -# 响应app文件 -@app.get("/", response_class=HTMLResponse) -async def _(): - # 读取 HTML 文件内容并返回 - with open(INDEX, "r", encoding="utf-8") as file: - html_content = file.read() - return HTMLResponse(content=html_content, status_code=200) - - # ---------------------------------- 加载动态路由 ---------------------------------- - - # 使用配置列表,统一导入 prefix = "/api/v1" app.include_router(test, prefix=prefix) diff --git a/vue/src/components/HomeSiderBar.vue b/vue/src/components/HomeSiderBar.vue index cc045aac..eb9d4f1e 100644 --- a/vue/src/components/HomeSiderBar.vue +++ b/vue/src/components/HomeSiderBar.vue @@ -9,10 +9,10 @@
From 4a95a82653878d62450e8b991dd4bceed0f6bc3b Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 17:48:22 +0800 Subject: [PATCH 07/36] Update router.py --- swanlab/server/router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swanlab/server/router.py b/swanlab/server/router.py index 3ad2b046..a456deb6 100644 --- a/swanlab/server/router.py +++ b/swanlab/server/router.py @@ -9,7 +9,7 @@ """ from fastapi import FastAPI -from fastapi.responses import HTMLResponse, PlainTextResponse +from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles import time From 24b23e8536286bdf06b96673dbacc6d8c6da1f22 Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 17:49:18 +0800 Subject: [PATCH 08/36] edit annotate --- swanlab/server/router.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/swanlab/server/router.py b/swanlab/server/router.py index a456deb6..bb65e159 100644 --- a/swanlab/server/router.py +++ b/swanlab/server/router.py @@ -72,8 +72,6 @@ async def resp_static(request, call_next): from .api.project import router as project from .api.experiment import router as experiment - -# ---------------------------------- 加载动态路由 ---------------------------------- # 使用配置列表,统一导入 prefix = "/api/v1" app.include_router(test, prefix=prefix) From 16f59cab3d2d8ecf4f02b3a91aae443f458bca90 Mon Sep 17 00:00:00 2001 From: Zirui Cai <1575079435@qq.com> Date: Mon, 11 Dec 2023 18:01:55 +0800 Subject: [PATCH 09/36] feat: extend block --- .../experiment/components/ExtendBlock.vue | 65 +++++++++++++++++++ .../experiment/pages/index/IndexPage.vue | 4 ++ .../index/components/ExperimentConfig.vue | 19 ++++++ .../index/components/ExperimentHeader.vue | 23 +++---- 4 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 vue/src/views/experiment/components/ExtendBlock.vue create mode 100644 vue/src/views/experiment/pages/index/components/ExperimentConfig.vue diff --git a/vue/src/views/experiment/components/ExtendBlock.vue b/vue/src/views/experiment/components/ExtendBlock.vue new file mode 100644 index 00000000..28ed26cf --- /dev/null +++ b/vue/src/views/experiment/components/ExtendBlock.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/vue/src/views/experiment/pages/index/IndexPage.vue b/vue/src/views/experiment/pages/index/IndexPage.vue index c049c6fc..24e90130 100644 --- a/vue/src/views/experiment/pages/index/IndexPage.vue +++ b/vue/src/views/experiment/pages/index/IndexPage.vue @@ -1,5 +1,8 @@ diff --git a/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue b/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue new file mode 100644 index 00000000..5eb9002f --- /dev/null +++ b/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue b/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue index 4ee1ed4a..4110ec32 100644 --- a/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue +++ b/vue/src/views/experiment/pages/index/components/ExperimentHeader.vue @@ -14,16 +14,16 @@ -
+
-
+
{{ $t(`experiment.header.experiment_infos.${item.title}`) }}
{{ item.value }}
-
+
{{ $t(`experiment.header.experiment_device.${item.title}`) }}
{{ item.value }}
@@ -34,8 +34,6 @@ diff --git a/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue b/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue index 8349d7de..3eb21f90 100644 --- a/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue +++ b/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue @@ -3,7 +3,7 @@

{{ $t('experiment.index.config.detail') }}

-
1
+

{{ $t('experiment.index.config.summarize') }}

@@ -20,6 +20,7 @@ * @since: 2023-12-11 17:07:31 **/ import ExtendBlock from '@swanlab-vue/views/experiment/components/ExtendBlock.vue' +import TableExample from './TableExample.vue' diff --git a/vue/src/views/experiment/pages/index/components/TableExample.vue b/vue/src/views/experiment/pages/index/components/TableExample.vue new file mode 100644 index 00000000..4953a2de --- /dev/null +++ b/vue/src/views/experiment/pages/index/components/TableExample.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/vue/src/views/home/HomeView.vue b/vue/src/views/home/HomeView.vue index 536d3dba..b666e2c4 100644 --- a/vue/src/views/home/HomeView.vue +++ b/vue/src/views/home/HomeView.vue @@ -34,7 +34,7 @@ - + {{ transTime(convertUtcToLocal(experiment.create_time)) }} From d84005e0ab20a4235abcc5f05d73df59ec7df09c Mon Sep 17 00:00:00 2001 From: KAAANG Date: Mon, 11 Dec 2023 20:49:01 +0800 Subject: [PATCH 14/36] delete name --- vue/src/views/experiment/pages/chart/ChartPage.vue | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vue/src/views/experiment/pages/chart/ChartPage.vue b/vue/src/views/experiment/pages/chart/ChartPage.vue index 7472c9f1..a25fa802 100644 --- a/vue/src/views/experiment/pages/chart/ChartPage.vue +++ b/vue/src/views/experiment/pages/chart/ChartPage.vue @@ -3,12 +3,7 @@

{{ experiment.name }}

- +
From a75b5a1d7cff8b42f57f243309978f35b14b2ca6 Mon Sep 17 00:00:00 2001 From: Zirui Cai <1575079435@qq.com> Date: Mon, 11 Dec 2023 21:11:14 +0800 Subject: [PATCH 15/36] feat: table --- vue/src/components/HomeSiderBar.vue | 8 ++++++-- .../views/experiment/components/ExtendBlock.vue | 5 ++++- .../pages/index/components/ExperimentConfig.vue | 17 ++++++++++++++--- .../pages/index/components/TableExample.vue | 8 ++++---- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/vue/src/components/HomeSiderBar.vue b/vue/src/components/HomeSiderBar.vue index eb9d4f1e..2c2fe261 100644 --- a/vue/src/components/HomeSiderBar.vue +++ b/vue/src/components/HomeSiderBar.vue @@ -41,10 +41,14 @@
diff --git a/vue/src/views/experiment/components/ExtendBlock.vue b/vue/src/views/experiment/components/ExtendBlock.vue index f567a8c8..23109da4 100644 --- a/vue/src/views/experiment/components/ExtendBlock.vue +++ b/vue/src/views/experiment/components/ExtendBlock.vue @@ -7,7 +7,10 @@ {{ title }} -
+
diff --git a/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue b/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue index 3eb21f90..fc1af45e 100644 --- a/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue +++ b/vue/src/views/experiment/pages/index/components/ExperimentConfig.vue @@ -1,9 +1,9 @@