Skip to content

Commit 19b5b2c

Browse files
feat/v0.1.4 (#198)
* ui: placeholder in search input * fixbug: duration * Update package.json --------- Co-authored-by: Zirui Cai <[email protected]>
1 parent b90d027 commit 19b5b2c

File tree

12 files changed

+47
-15
lines changed

12 files changed

+47
-15
lines changed

swanlab/data/run/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ def __set_exp_status(self, status: int):
193193
for index, experiment in enumerate(project["experiments"]):
194194
if experiment["experiment_id"] == self.__exp.id:
195195
project["experiments"][index]["status"] = status
196-
project["update_time"] = create_time()
196+
time = create_time()
197+
project["experiments"][index]["update_time"] = time
198+
project["update_time"] = time
197199
break
198200
file.truncate(0)
199201
file.seek(0)

swanlab/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swanlab",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "",
55
"python": "true"
66
}

swanlab/server/api/experiment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ async def get_experiment_status(experiment_id: int):
259259
"""
260260
exp = __find_experiment(experiment_id)
261261
status = exp["status"]
262+
update_time = exp["update_time"]
262263
chart_path: str = os.path.join(SWANLOG_DIR, exp["name"], "chart.json")
263264
charts = __get_charts(chart_path)
264-
return SUCCESS_200(data={"status": status, "charts": charts})
265+
return SUCCESS_200(data={"status": status, "update_time": update_time, "charts": charts})
265266

266267

267268
@router.get("/{experiment_id}/summary")

vue/src/i18n/en-US/experiment.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
"func-bar": {
102102
"copy": "Copy",
103103
"download": "Download",
104-
"copy-success": "Copied"
104+
"copy-success": "Copied",
105+
"placeholder": {
106+
"requirements": "Search requirement...",
107+
"log": "Search log..."
108+
}
105109
}
106110
}

vue/src/i18n/zh-CN/experiment.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
"func-bar": {
9595
"copy": "Copy",
9696
"download": "Download",
97-
"copy-success": "Copied"
97+
"copy-success": "Copied",
98+
"placeholder": {
99+
"requirements": "Search requirement...",
100+
"log": "Search log..."
101+
}
98102
}
99103
}

vue/src/store/modules/experiment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
22
import { computed, ref } from 'vue'
33
import { t } from '@swanlab-vue/i18n'
44

5-
export const useExperimentStroe = defineStore('charts', () => {
5+
export const useExperimentStroe = defineStore('experiment', () => {
66
/** state */
77
// 当前实验
88
const experiment = ref()
@@ -71,7 +71,7 @@ export const useExperimentStroe = defineStore('charts', () => {
7171
experiment.value.status = status
7272
}
7373
// 修改更新时间
74-
const setUpateTIme = (time) => {
74+
const setUpateTime = (time) => {
7575
experiment.value.update_time = time
7676
}
7777

@@ -96,7 +96,7 @@ export const useExperimentStroe = defineStore('charts', () => {
9696
duration,
9797
// action
9898
setStatus,
99-
setUpateTIme,
99+
setUpateTime,
100100
setExperiment
101101
}
102102
})

vue/src/store/modules/project.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ export const useProjectStore = defineStore('project', () => {
2727
* 设置指定实验的状态
2828
* @param { number } id 实验id
2929
* @param { string } status 实验状态
30+
* @param { number } update_time 实验更新时间
3031
*/
31-
const setExperimentStatus = (id, status) => {
32+
const setExperimentStatus = (id, status, update_time) => {
3233
// 不需要绝对等于
3334
const experiment = experiments.value.find((e) => e.experiment_id == id)
3435
experiment.status = status
36+
if (update_time) experiment.update_time = update_time
3537
}
3638
/**
3739
* 重置实验列表中某一个实验的信息

vue/src/views/experiment/ExperimentView.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const init = async (id = route.params.experimentId) => {
3737
.then(({ data }) => {
3838
experimentStore.experiment = data
3939
// 设置实验状态
40-
projectStore.setExperimentStatus(data.experiment_id, data.status)
40+
projectStore.setExperimentStatus(data.experiment_id, data.status, data.update_time)
4141
// 如果实验状态还在running,就轮询
4242
if (experimentStore.isRunning) polling()
4343
})
@@ -70,7 +70,8 @@ const polling = () => {
7070
}
7171
// 设置实验状态
7272
experimentStore.setStatus(data.status)
73-
projectStore.setExperimentStatus(experimentStore.id, data.status)
73+
experimentStore.setUpateTime(data.update_time)
74+
projectStore.setExperimentStatus(experimentStore.id, data.status, data.update_time)
7475
experimentStore.charts = data.charts
7576
7677
if (!experimentStore.isRunning) {

vue/src/views/experiment/components/FuncBar.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="w-full flex gap-5 justify-between">
3-
<SLSearch @input="input" class="max-w-[400px]" />
3+
<SLSearch @input="input" :placeholder="placeholder" class="max-w-[400px]" />
44
<div class="flex gap-3">
55
<SLButton hollow @click="copy">
66
<SLIcon icon="copy" class="icon"></SLIcon>
@@ -36,6 +36,11 @@ const props = defineProps({
3636
filename: {
3737
type: String,
3838
default: 'swanlab.file'
39+
},
40+
// 搜索栏的占位
41+
placeholder: {
42+
type: String,
43+
default: 'Search...'
3944
}
4045
})
4146

vue/src/views/experiment/pages/environment/pages/EnvRequirements.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
<div class="w-full" v-if="requirements">
33
<template v-if="requirements.length !== 0">
44
<!-- 搜索、复制、下载 -->
5-
<FuncBar class="pb-6 py-4" @input="search" :content="requirements?.join('\n')" :filename="filename" />
5+
<FuncBar
6+
class="pb-6 py-4"
7+
@input="search"
8+
:content="requirements?.join('\n')"
9+
:filename="filename"
10+
:placeholder="$t('experiment.func-bar.placeholder.requirements')"
11+
/>
612
<!-- 如果有依赖项 -->
713
<div class="px-6 py-4 bg-higher rounded">
814
<p v-for="line in lines" :key="line">

0 commit comments

Comments
 (0)