feat(data-process): 接入重新生成配置流程
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import PageCard from '@/components/PageCard.vue'
|
||||
import ModelStatusTag from '@/components/ModelStatusTag.vue'
|
||||
import { usePolling } from '@/composables/usePolling'
|
||||
@@ -167,11 +167,14 @@ const outputDatasets = computed(() => {
|
||||
const outputDatasetName = computed(() => (
|
||||
outputDatasets.value.map((item) => item.name).join('、')
|
||||
))
|
||||
const outputDatasetBaseName = computed(() => {
|
||||
const name = String(outputDatasets.value[0]?.name || '').trim()
|
||||
return name.replace(/-(?:训练集|验证集|测试集)$/, '')
|
||||
})
|
||||
const outputDatasetId = computed(() => detail.value?.output_dataset_id || null)
|
||||
const canRegenerate = computed(() => {
|
||||
const status = detail.value?.status
|
||||
return status === 'pending'
|
||||
|| status === 'failed'
|
||||
|| status === 'stopped'
|
||||
|| (status === 'completed' && Boolean(outputDatasetId.value))
|
||||
})
|
||||
const creatorName = computed(() => detail.value?.creator_name || detail.value?.creator || '-')
|
||||
const createTime = computed(() => detail.value?.create_time || detail.value?.created_at)
|
||||
const startTime = computed(() => detail.value?.start_time || detail.value?.started_at)
|
||||
@@ -428,10 +431,6 @@ function configuredSplit(): DataProcessDatasetSplit {
|
||||
|
||||
function openPublishDialog() {
|
||||
if (!detail.value) return
|
||||
if (outputDatasetId.value) {
|
||||
void router.push({ path: '/dataset', query: { tab: 'task', task_id: taskId.value } })
|
||||
return
|
||||
}
|
||||
publishForm.dataset_name = `${detail.value.name}-数据集`
|
||||
publishForm.split = configuredSplit()
|
||||
publishDialogVisible.value = true
|
||||
@@ -461,31 +460,8 @@ async function publishDataset() {
|
||||
}
|
||||
}
|
||||
|
||||
async function resyncPublishedDataset() {
|
||||
if (!detail.value || !outputDatasetId.value || publishing.value) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'将按当前 8:1:1 配置同步为训练集、验证集、测试集三个独立数据集。',
|
||||
'重新同步三个数据集?',
|
||||
{ type: 'warning', confirmButtonText: '重新同步', cancelButtonText: '取消' },
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
publishing.value = true
|
||||
try {
|
||||
const published = await publishDataProcess(taskId.value, {
|
||||
...publishForm,
|
||||
dataset_name: outputDatasetBaseName.value || `${detail.value.name}-数据集`,
|
||||
split: configuredSplit(),
|
||||
})
|
||||
const datasets = published.datasets || published.output_datasets || []
|
||||
ElMessage.success(`训练集、验证集和测试集已同步,共 ${datasets.length || 3} 个数据集`)
|
||||
await router.push({ path: '/dataset', query: { tab: 'task', task_id: taskId.value } })
|
||||
} finally {
|
||||
publishing.value = false
|
||||
}
|
||||
function startRegeneration() {
|
||||
void router.push({ name: 'data-process-regenerate', params: { id: taskId.value } })
|
||||
}
|
||||
|
||||
watch([currentPage, pageSize], () => void loadResults())
|
||||
@@ -504,20 +480,20 @@ onBeforeUnmount(() => {
|
||||
<h1>{{ detail.name }}</h1>
|
||||
<ModelStatusTag :status="detail.status" />
|
||||
<el-button
|
||||
v-if="detail.status === 'completed'"
|
||||
v-if="detail.status === 'completed' && !outputDatasetId"
|
||||
class="publish-button"
|
||||
type="primary"
|
||||
@click="openPublishDialog"
|
||||
>
|
||||
<i class="fa" :class="outputDatasetId ? 'fa-external-link' : 'fa-database'" />
|
||||
{{ outputDatasetId ? '查看三个数据集' : '发布为三个数据集' }}
|
||||
<i class="fa fa-database" />发布为三个数据集
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="detail.status === 'completed' && outputDatasetId"
|
||||
:loading="publishing"
|
||||
@click="resyncPublishedDataset"
|
||||
v-if="canRegenerate"
|
||||
class="publish-button"
|
||||
type="primary"
|
||||
@click="startRegeneration"
|
||||
>
|
||||
<i class="fa fa-refresh" />重新同步数据集
|
||||
<i class="fa fa-refresh" />重新生成
|
||||
</el-button>
|
||||
</div>
|
||||
<p>{{ detail.description || '暂无任务描述' }}</p>
|
||||
|
||||
Reference in New Issue
Block a user