소스 검색

增加机器学习配置选项

Prevalence 7 년 전
부모
커밋
a74448d096
3개의 변경된 파일54개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 1
      src/api/dlwork.js
  2. 45 0
      src/components/AssignmentCRUD/CreateAssignment/index.vue
  3. 4 2
      vue.config.js

+ 5 - 1
src/api/dlwork.js

@@ -43,6 +43,8 @@ export const getStudentDLProjectDetail = (dlworkId, userId) => {
  * 老师新建机器学习作业
  * @param type
  * @param name
+ * @param dltype 机器学习框架类型,0为Tensorflow,1为Pytorch
+ * @param useGPU 是否使用GPU
  * @param description
  * @param startAt
  * @param endAt
@@ -51,7 +53,7 @@ export const getStudentDLProjectDetail = (dlworkId, userId) => {
  * @returns {Promise<*>}
  */
 export const postDLAssignment = (
-  { type, name, description, startAt, endAt, problem },
+  { type, name, dltype, useGPU, description, startAt, endAt, problem },
   courseId
 ) => {
   return request(`${DL_WORK_MODULE}/course/${courseId}/dlwork`, {
@@ -59,6 +61,8 @@ export const postDLAssignment = (
     body: {
       type: type || null,
       name: name || null,
+      dltype: dltype || 0,
+      useGPU: useGPU || false,
       description: description || null,
       startAt: startAt || null,
       endAt: endAt || null,

+ 45 - 0
src/components/AssignmentCRUD/CreateAssignment/index.vue

@@ -22,6 +22,33 @@
               v-model="$v.params.name.$model"
             ></b-input>
           </b-field>
+          <b-field
+            label="作业配置"
+            :type="$v.params.dltype.$error ? 'is-danger' : ''"
+            :message="$v.params.dltype.$error ? '请选择机器学习作业配置' : ''"
+          >
+          </b-field>
+          <div style="display: flex; margin-bottom: 0.5em">
+            <b-radio
+              name="dltype"
+              value="0"
+              v-model="$v.params.dltype"
+              style="flex: 1"
+            >
+              Tensorflow
+            </b-radio>
+            <b-radio
+              name="dltype"
+              value="1"
+              v-model="$v.params.dltype"
+              style="flex: 1"
+              >Pytorch
+            </b-radio>
+            <b-checkbox value="false" v-model="$v.params.useGPU"
+              >是否使用GPU</b-checkbox
+            >
+          </div>
+
           <b-field
             label="作业描述"
             :type="$v.params.description.$error ? 'is-danger' : ''"
@@ -180,7 +207,13 @@ import { required } from "vuelidate/lib/validators";
 import pathMixins from "@/mixins/path";
 import { difficultyType } from "@/data/questionDifficulty";
 import { difficultyClass } from "@/data/questionDifficulty";
+import BInput from "buefy/src/components/input/Input";
+import BField from "buefy/src/components/field/Field";
+import BRadio from "buefy/src/components/radio/Radio";
+import BCheckbox from "buefy/src/components/checkbox/Checkbox";
+
 export default {
+  components: { BCheckbox, BRadio, BField, BInput },
   props: {
     courseId: {
       type: Number
@@ -205,6 +238,8 @@ export default {
     return {
       params: {
         name: null,
+        dltype: 0,
+        useGPU: false,
         description: null,
         startAt: null,
         endAt: null,
@@ -372,6 +407,12 @@ export default {
       name: {
         required
       },
+      dltype: {
+        required
+      },
+      useGPU: {
+        required
+      },
       description: {
         required
       },
@@ -405,13 +446,16 @@ export default {
 .card {
   text-align: left;
   padding: 30px;
+
   .title {
     font-size: 1.25rem;
+
     small {
       color: gray;
       font-size: 1rem;
     }
   }
+
   .content {
     a {
       margin-top: 30px;
@@ -419,6 +463,7 @@ export default {
     }
   }
 }
+
 .description {
   overflow: hidden;
   text-overflow: ellipsis;

+ 4 - 2
vue.config.js

@@ -2,8 +2,10 @@ module.exports = {
   devServer: {
     proxy: {
       "^/api": {
-        target: "http://localhost:18080/",
-        //target: "http://10.1.1.198:8080/",
+        // target: "http://localhost:18080/",
+        target: "http://localhost:4000/",
+
+        // target: "http://10.1.1.198:8080/",
         //target: "http://192.168.0.101:8080",
         // target: "http://10.1.2.3:8080/",