Kaynağa Gözat

分步执行

zhengnaiwen_citu 5 gün önce
ebeveyn
işleme
cf6450e18c

+ 2 - 2
src/api/dataChart.js

@@ -136,7 +136,7 @@ export function saveDataBase (taskId, param) {
 }
 // 表名清单管理 上传表清单文件
 export function uploadDataTasksList (taskId, param) {
-  return http.upload(`/vanna/v0/data_pipeline/tasks/${taskId}/upload-table-li`, param)
+  return http.upload(`/vanna/v0/data_pipeline/tasks/${taskId}/upload-table-list`, param)
 }
 // 表名清单管理 获取表清单文件信息
 export function getDataTasksFileList (param) {
@@ -150,7 +150,7 @@ export function getTasksFileList (taskId, param) {
   return http.get(`/vanna/v0/data_pipeline/tasks/${taskId}/files`, param)
 }
 
-// 训练数据文件管理 查看任务文件列表
+// 训练数据文件管理 下载任务文件
 export function downloadTasksFileList (taskId, fileName) {
   return http.getDownload(`/vanna/v0/data_pipeline/tasks/${taskId}/files/${fileName}`)
 }

+ 1 - 1
src/views/dataChart/dataChartEditChat.vue

@@ -329,7 +329,7 @@ export default {
         this.conversationId = data.conversation_id
         this.scrollToBottom()
       } catch (error) {
-        ask.content = error.message
+        ask.content = error.message ?? error
       } finally {
         this.disabled = false
       }

+ 31 - 4
src/views/modelSystem/modelQa/index.vue

@@ -2,18 +2,26 @@
   <div class="pa-3 white">
     <m-filter :option="filter" @search="handleSearch" />
     <m-table
+      ref="tableRefs"
+      class="mt-3"
       :loading="loading"
       :headers="headers"
       :items="items"
       :total="total"
       :page-info="pageInfo"
-      :show-select="false"
       :is-tools="false"
-      @edit="handleEdit"
       @delete="handleDelete"
       @pageHandleChange="pageHandleChange"
       @sort="handleSort"
     >
+      <template #navBtn>
+        <v-btn class="buttons" rounded color="primary" @click="handleAddTo()">添加到训练集</v-btn>
+      </template>
+      <template #actions="{ item }">
+        <v-btn color="primary" text @click="handleEdit(item)">编辑</v-btn>
+        <v-btn color="primary" text :disabled="item.is_in_training_data" @click="handleAddTo([item.id])">添加到训练集</v-btn>
+        <v-btn color="error" text @click="handleDelete(item.id)">删除</v-btn>
+      </template>
       <template #is_thumb_up="{ item }">
         <v-chip :color="item.is_thumb_up ? 'success' : 'error'" small>{{ item.is_thumb_up ? '赞同' : '不赞同' }}</v-chip>
       </template>
@@ -38,7 +46,8 @@ import MTable from '@/components/List/table.vue'
 import ModelQaEdit from './modelQaEdit.vue'
 import {
   getFeedbackList,
-  deleteFeedback
+  deleteFeedback,
+  addFeedbackToTraining
 } from '@/api/dataChart'
 export default {
   name: 'model-qa',
@@ -73,7 +82,7 @@ export default {
       headers: [
         { text: '问题', align: 'start', value: 'question' },
         { text: 'sql', align: 'start', value: 'sql' },
-        { text: '赞同与否', align: 'center', value: 'is_thumb_up' },
+        { text: '反馈', align: 'center', value: 'is_thumb_up' },
         { text: '是否已加入训练数据', align: 'center', value: 'is_in_training_data' },
         { text: '创建时间', align: 'start', value: 'create_time' },
         { text: '操作', align: 'start', value: 'actions' }
@@ -116,6 +125,24 @@ export default {
     async handleEdit (item) {
       this.$refs.modelQaEditRefs.open(item)
     },
+    handleAddTo (ids) {
+      console.log(ids)
+      const feedbackIds = ids ?? this.$refs.tableRefs.ids
+      console.log(feedbackIds)
+      if (!feedbackIds.length) {
+        this.$snackbar.warning('请选择需要添加的数据')
+        return
+      }
+      this.$confirm('提示', '是否添加到训练集').then(async _ => {
+        try {
+          await addFeedbackToTraining({ feedback_ids: feedbackIds })
+          this.$snackbar.success('添加成功')
+          this.init()
+        } catch (error) {
+          this.$snackbar.error('添加失败')
+        }
+      })
+    },
     handleDelete (ids, item) {
       this.$confirm('提示', '是否删除该选项')
         .then(async () => {

+ 3 - 3
src/views/modelSystem/modelQa/modelQaEdit.vue

@@ -32,16 +32,16 @@ export default {
           rows: 10
         },
         {
-          label: '是否赞同',
+          label: '用户反馈',
           key: 'is_thumb_up',
           type: 'ifRadio',
           items: [
             {
-              label: '',
+              label: '赞同',
               value: true
             },
             {
-              label: '',
+              label: '不赞同',
               value: false
             }
           ]

+ 22 - 4
src/views/modelSystem/modelTrain/index.vue

@@ -18,9 +18,11 @@
       </template>
       <template #actions="{ item }">
         <v-btn color="success" text @click="handleExecute(item.task_id)">执行</v-btn>
-        <v-btn color="primary" text @click="handleFindExecute(item.task_id)">查看执行进度</v-btn>
+        <!-- <v-btn color="success" text @click="handleExecuteStep(item.task_id)">分步执行</v-btn> -->
+        <v-btn color="primary" text @click="handleFindExecute(item.task_id)">执行进度</v-btn>
         <v-btn color="primary" text @click="handleTable(item.task_id)">表名清单</v-btn>
-        <v-btn color="primary" text @click="handleLog(item.task_id)">查看日志</v-btn>
+        <v-btn color="primary" text @click="handleFiles(item.task_id)">任务文件</v-btn>
+        <v-btn color="primary" text @click="handleLog(item.task_id)">运行日志</v-btn>
         <v-btn color="error" text @click="handleDelete([item.task_id])">删除</v-btn>
       </template>
     </m-table>
@@ -28,6 +30,8 @@
     <ModelTrainStatus ref="modelTrainStatusRefs"></ModelTrainStatus>
     <ModelTrainTable ref="modelTrainTableRefs"></ModelTrainTable>
     <ModelTrainLog ref="modelTrainLogRefs"></ModelTrainLog>
+    <ModelTrainFiles ref="modelTrainFilesRefs"></ModelTrainFiles>
+    <ModelTrainStep ref="modelTrainStepRefs"></ModelTrainStep>
   </div>
 </template>
 
@@ -38,6 +42,8 @@ import ModelTrainEdit from './modelTrainEdit.vue'
 import ModelTrainStatus from './modelTrainStatus.vue'
 import ModelTrainTable from './modelTrainTable.vue'
 import ModelTrainLog from './modelTrainLog.vue'
+import ModelTrainFiles from './modelTrainFiles.vue'
+import ModelTrainStep from './modelTrainStep.vue'
 import {
   // createDataTasks,
   executeDataTasks,
@@ -52,7 +58,9 @@ export default {
     ModelTrainEdit,
     ModelTrainStatus,
     ModelTrainTable,
-    ModelTrainLog
+    ModelTrainLog,
+    ModelTrainFiles,
+    ModelTrainStep
   },
   data () {
     return {
@@ -122,6 +130,10 @@ export default {
     handleTable (id) {
       this.$refs.modelTrainTableRefs.open(id)
     },
+    // 查看任务文件
+    handleFiles (id) {
+      this.$refs.modelTrainFilesRefs.open(id)
+    },
     handleLog (id) {
       this.$refs.modelTrainLogRefs.open(id)
     },
@@ -135,12 +147,18 @@ export default {
         this.$snackbar.error(error)
       }
     },
+    handleExecuteStep (id) {
+      this.$refs.modelTrainStepRefs.open(id)
+    },
     handleDelete (ids) {
       if (Array.isArray(ids) && !ids.length) return this.$snackbar.warning('请选择要删除的选项')
       this.$confirm('提示', '是否删除该选项')
         .then(async () => {
           try {
-            await deleteDataTasks({ ids })
+            await deleteDataTasks({
+              task_ids: ids,
+              confirm: true
+            })
             this.$snackbar.success('删除成功')
             this.init()
           } catch (error) {

+ 152 - 0
src/views/modelSystem/modelTrain/modelTrainFiles.vue

@@ -0,0 +1,152 @@
+<template>
+  <m-dialog title="任务文件" :visible.sync="show" :footer="false">
+    <m-table
+      class="mt-3"
+      elevation="0"
+      :loading="loading"
+      :headers="headers"
+      :items="items"
+      :total="total"
+      :disable-sort="true"
+      :is-tools="false"
+      :show-select="false"
+      :showPage="false"
+    >
+      <template #navBtn>
+        <v-btn class="buttons" rounded color="primary" @click="showUpload = true">文件上传</v-btn>
+      </template>
+      <template #actions="{ item }">
+        <v-btn text color="primary" :loading="item.loading" @click="handleDownload(item)">下载文件</v-btn>
+      </template>
+    </m-table>
+    <m-dialog title="文件上传" :visible.sync="showUpload" @submit="handleSubmitFiles">
+      <div style="width: 500px; margin: 0 auto; min-height: 300px;">
+        <div class="d-flex">
+          <div class="mr-5">上传文件</div>
+          <v-file-input
+            v-model="file"
+            label="点击上传"
+            outlined
+            hide-details
+            dense
+          ></v-file-input>
+        </div>
+        <div class="d-flex">
+          <div class="mt-5 mr-5">上传模式</div>
+          <v-radio-group
+            v-model="overwriteMode"
+          >
+            <v-radio
+              label="备份模式"
+              value="backup"
+            ></v-radio>
+            <v-radio
+              label="替换模式"
+              value="replace"
+            ></v-radio>
+            <v-radio
+              label="跳过模式"
+              value="skip"
+            ></v-radio>
+          </v-radio-group>
+        </div>
+      </div>
+    </m-dialog>
+  </m-dialog>
+</template>
+
+<script>
+import MDialog from '@/components/Dialog'
+import MTable from '@/components/List/table.vue'
+import {
+  getTasksFileList,
+  downloadTasksFileList,
+  uploadTasksList
+} from '@/api/dataChart'
+import { downloadFile } from '@/utils'
+export default {
+  name: 'modelTrainFiles',
+  components: {
+    MDialog,
+    MTable
+  },
+  data () {
+    return {
+      file: null,
+      overwriteMode: 'backup',
+      showUpload: false,
+      show: false,
+      id: null,
+      loading: false,
+      headers: [
+        { text: '文件名', value: 'file_name' },
+        { text: '文件类型', value: 'file_type' },
+        { text: '文件大小', value: 'file_size_formatted' },
+        { text: '操作', value: 'actions' }
+      ],
+      items: [],
+      total: 0,
+      pageInfo: {
+        current: 1,
+        size: 10
+      }
+    }
+  },
+  methods: {
+    open (id) {
+      this.id = id
+      this.show = true
+      this.getList()
+    },
+    async getList () {
+      this.loading = true
+      try {
+        const { data } = await getTasksFileList(this.id)
+        this.items = data.files.map(e => {
+          return {
+            ...e,
+            loading: false
+          }
+        })
+        this.total = data.directory_info.total_files
+      } catch (error) {
+        this.$snackbar.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    async handleDownload (item) {
+      try {
+        item.loading = true
+        const { data, name } = await downloadTasksFileList(this.id, item.file_name)
+        downloadFile(data, name)
+      } catch (error) {
+        this.$snackbar.error(error)
+      } finally {
+        item.loading = false
+      }
+    },
+    async handleSubmitFiles () {
+      if (!this.file) {
+        this.$snackbar.error('请选择文件')
+        return
+      }
+      const query = new FormData()
+      query.append('file', this.file)
+      query.append('overwrite_mode', this.overwriteMode)
+      try {
+        await uploadTasksList(this.id, query)
+        this.$snackbar.success('上传成功')
+        this.showUpload = false
+        this.getList()
+      } catch (error) {
+        this.$snackbar.error(error)
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 1 - 1
src/views/modelSystem/modelTrain/modelTrainLog.vue

@@ -22,7 +22,7 @@
       <!-- <v-btn rounded color="primary" class="ml-3 half-button">查 询</v-btn> -->
     </div>
     <v-timeline
-      :reverse="reverse"
+      :reverse="false"
       dense
     >
       <v-timeline-item

+ 65 - 28
src/views/modelSystem/modelTrain/modelTrainStatus.vue

@@ -1,37 +1,47 @@
 <template>
   <m-dialog title="任务进度" :visible.sync="show" :footer="false">
-    <v-stepper
-      alt-labels
-      class="my-12"
-      elevation="0"
-      v-loading="loading"
-    >
-      <v-stepper-header>
-        <template
-          v-for="(status, index) in statusItems"
-        >
-          <v-stepper-step
-            :key="status.key"
-            :step="index + 1"
-            :complete="status.value === 'completed'"
-            :rules="[() => status.value !== 'failed']"
+    <div style="min-height: 300px; " v-loading="loading">
+      <div class="text-right">
+        <v-btn color="primary" @click="getStatus">
+          <v-icon left>mdi-refresh</v-icon>
+          刷新
+        </v-btn>
+      </div>
+      <v-stepper
+        alt-labels
+        class="my-12"
+        elevation="0"
+      >
+        <v-stepper-header>
+          <template
+            v-for="(status, index) in statusItems"
           >
-            {{ status.key }}
-            <div class="mt-3">
-              <v-chip>{{ status.value }}</v-chip>
-            </div>
-          </v-stepper-step>
+            <v-stepper-step
+              :key="status.key"
+              :step="index + 1"
+              :complete="status.value === 'completed'"
+              :rules="[() => status.value !== 'failed']"
+            >
+              {{ status.key }}
+              <div class="mt-3 text-center">
+                <v-chip :color="statusList[status.value]">{{ status.value }}</v-chip>
+              </div>
+              <div class="text-center mt-3">
+                <v-btn color="primary" :loading="status.loading" @click="handleRun(status)">重新执行</v-btn>
+              </div>
+            </v-stepper-step>
 
-          <v-divider :key="status.key" v-if="index < statusItems.length - 1"></v-divider>
-        </template>
-      </v-stepper-header>
-    </v-stepper>
+            <v-divider :key="status.key" v-if="index < statusItems.length - 1"></v-divider>
+          </template>
+        </v-stepper-header>
+      </v-stepper>
+    </div>
   </m-dialog>
 </template>
 
 <script>
 import MDialog from '@/components/Dialog'
-import { getDataTasksStatus } from '@/api/dataChart'
+import { getDataTasksStatus, executeDataTasks } from '@/api/dataChart'
 export default {
   name: 'modelTrainStatus',
   components: {
@@ -39,21 +49,33 @@ export default {
   },
   data () {
     return {
+      statusList: {
+        preparing: 'primary',
+        completed: 'success',
+        failed: 'error',
+        pending: 'warning'
+      },
       show: false,
       loading: false,
-      statusItems: []
+      statusItems: [],
+      id: null
     }
   },
   methods: {
     async open (id) {
+      this.id = id
       this.show = true
+      this.getStatus()
+    },
+    async getStatus () {
       this.loading = true
       try {
-        const { data } = await getDataTasksStatus(id)
+        const { data } = await getDataTasksStatus(this.id)
         this.statusItems = Object.keys(data.step_status).map(key => {
           return {
             key,
-            value: data.step_status[key]
+            value: data.step_status[key],
+            loading: false
           }
         })
       } catch (error) {
@@ -61,6 +83,21 @@ export default {
       } finally {
         this.loading = false
       }
+    },
+    async handleRun (item) {
+      item.loading = true
+      try {
+        await executeDataTasks(this.id, {
+          execution_mode: 'step',
+          step_name: item.key
+        })
+        this.$snackbar.success('任务已启动')
+        this.getStatus()
+      } catch (error) {
+        this.$snackbar.error(error)
+      } finally {
+        item.loading = false
+      }
     }
   }
 }

+ 90 - 0
src/views/modelSystem/modelTrain/modelTrainStep.vue

@@ -0,0 +1,90 @@
+<template>
+  <m-dialog title="分步执行" :visible.sync="show" :footer="false">
+    <v-stepper v-model="stepValue">
+      <v-stepper-header>
+        <template v-for="(step, index) in steps">
+          <v-stepper-step
+            :key="step.value"
+            :step="index"
+            editable
+          >
+            {{ step.text }}
+          </v-stepper-step>
+
+          <v-divider
+            v-if="steps.length - 1 !== index"
+            :key="step.value"
+          ></v-divider>
+        </template>
+      </v-stepper-header>
+
+      <v-stepper-items>
+        <v-stepper-content
+          v-for="(step, index) in steps"
+          :key="step.value"
+          :step="index"
+        >
+          <v-card
+            class="mb-12"
+            color="grey lighten-1"
+            height="200px"
+          ></v-card>
+
+          <div class="text-center">
+            <v-btn
+              color="success"
+              @click="handleRunStep(index)"
+            >
+              <v-icon left>mdi-send</v-icon>
+              开始执行
+            </v-btn>
+          </div>
+        </v-stepper-content>
+      </v-stepper-items>
+    </v-stepper>
+  </m-dialog>
+</template>
+
+<script>
+import MDialog from '@/components/Dialog'
+import {
+  executeDataTasks
+} from '@/api/dataChart'
+export default {
+  name: 'modelTrainStep',
+  components: {
+    MDialog
+  },
+  data () {
+    return {
+      show: false,
+      stepValue: 0,
+      steps: [
+        { text: 'DDL/MD文档生成', value: 'ddl_generation' },
+        { text: 'Question-SQL对生成', value: 'qa_generation' },
+        { text: 'SQL验证和修复', value: 'sql_validation' },
+        { text: '训练数据加载', value: 'training_load' }
+      ],
+      id: null
+    }
+  },
+  methods: {
+    open (id) {
+      this.id = id
+      this.show = true
+    },
+    async handleRunStep (index) {
+      try {
+        const { data } = await executeDataTasks(this.id, {})
+        console.log(data)
+      } catch (error) {
+        this.$snackbar.error(error)
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 14 - 10
src/views/modelSystem/modelTrain/modelTrainTable.vue

@@ -4,19 +4,23 @@
       <v-btn class="mr-3" color="primary" rounded @click="handleAdd">修改表名</v-btn>
       <UploadBtn color="primary" @change="handleChangeFile">导入表名</UploadBtn>
     </div>
-    <v-list
-      subheader
+    <div
+      style="min-height: 300px;"
       v-loading="loading"
     >
-      <v-list-item
-        v-for="item in items"
-        :key="item"
+      <v-list
+        subheader
       >
-        <v-list-item-content>
-          <v-list-item-title>{{ item }}</v-list-item-title>
-        </v-list-item-content>
-      </v-list-item>
-    </v-list>
+        <v-list-item
+          v-for="item in items"
+          :key="item"
+        >
+          <v-list-item-content>
+            <v-list-item-title>{{ item }}</v-list-item-title>
+          </v-list-item-content>
+        </v-list-item>
+      </v-list>
+    </div>
     <ModelTrainTableSubmit ref="modelTrainTableSubmitRefs" @success="getData"></ModelTrainTableSubmit>
   </m-dialog>
 </template>