You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

modelmanage-local-create-1.vue 12 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <div>
  3. <div class="header">
  4. <span class="title">{{ type == '1' ? '修改模型信息' : '导入本地模型' }}</span>
  5. </div>
  6. <div class="content">
  7. <div class="guide-c" v-if="type != '1'">
  8. <div class="step focused">
  9. <div class="num">1</div>
  10. <div class="txt">创建模型</div>
  11. </div>
  12. <div class="line"></div>
  13. <div class="step">
  14. <div class="num">2</div>
  15. <div class="txt">上传模型文件</div>
  16. </div>
  17. </div>
  18. <div class="row-c" v-loading="loading">
  19. <div class="row">
  20. <div class="r-title"><label class="required">可用集群</label></div>
  21. <div class="r-content" style="display:flex;">
  22. <div class="cluster-type-btn" v-if="type != 1 || type == 1 && state.type === 0"
  23. :class="state.type === 0 ? 'focused' : ''"
  24. :style="type != 1 ? 'border-top-right-radius:unset;border-bottom-right-radius:unset;' : ''"
  25. @click="state.type = 0">
  26. <svg xmlns="http://www.w3.org/2000/svg"
  27. class="icon styles__StyledSVGIconPathComponent-sc-16fsqc8-0 cSaWDI svg-icon-path-icon fill"
  28. viewBox="0 0 32 32" width="16" height="16">
  29. <defs data-reactroot=""></defs>
  30. <g>
  31. <path
  32. d="M4 3.989c0-0.731 0.593-1.323 1.324-1.323h21.352c0.729 0.005 1.318 0.594 1.324 1.322v24.022c-0.001 0.731-0.593 1.323-1.324 1.323h-21.352c-0.729-0.005-1.318-0.594-1.324-1.322v-24.022zM25.333 14.667v-9.333h-18.667v9.333h18.667zM25.333 17.333h-18.667v9.333h18.667v-9.333zM12 8h8v2.667h-8v-2.667zM12 20h8v2.667h-8v-2.667z">
  33. </path>
  34. </g>
  35. </svg>
  36. <span class="txt">CPU / GPU</span>
  37. </div>
  38. <div class="cluster-type-btn" v-if="type != 1 || type == 1 && state.type === 1"
  39. :class="state.type === 1 ? 'focused' : ''"
  40. :style="type != 1 ? 'border-top-left-radius:unset;border-bottom-left-radius:unset;' : ''"
  41. @click="state.type = 1">
  42. <svg xmlns="http://www.w3.org/2000/svg"
  43. class="icon styles__StyledSVGIconPathComponent-sc-16fsqc8-0 iKfgJk svg-icon-path-icon fill"
  44. viewBox="0 0 32 32" width="16" height="16">
  45. <defs data-reactroot=""></defs>
  46. <g>
  47. <path
  48. d="M4 3.989c0-0.731 0.593-1.323 1.324-1.323h21.352c0.729 0.005 1.318 0.594 1.324 1.322v24.022c-0.001 0.731-0.593 1.323-1.324 1.323h-21.352c-0.729-0.005-1.318-0.594-1.324-1.322v-24.022zM25.333 14.667v-9.333h-18.667v9.333h18.667zM25.333 17.333h-18.667v9.333h18.667v-9.333zM12 8h8v2.667h-8v-2.667zM12 20h8v2.667h-8v-2.667z">
  49. </path>
  50. </g>
  51. </svg>
  52. <span class="txt">Ascend NPU</span>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="row">
  57. <div class="r-title"><label class="required">模型名称</label></div>
  58. <div class="r-content">
  59. <el-input size="medium" :maxLength="25" v-model="state.name" placeholder="请输入模型名称"></el-input>
  60. </div>
  61. </div>
  62. <div class="row">
  63. <div class="r-title"><label class="required">版本</label></div>
  64. <div class="r-content">
  65. <el-input class="input-disabled" style="width:288px;" size="medium" v-model="state.version" readonly>
  66. </el-input>
  67. </div>
  68. </div>
  69. <div class="row">
  70. <div class="r-title"><label class="required">模型框架</label></div>
  71. <div class="r-content">
  72. <el-select style="width:288px;" size="medium" v-model="state.engine" placeholder="请选择">
  73. <el-option v-for="item in engineList" :key="item.k" :label="item.v" :value="item.k">
  74. </el-option>
  75. </el-select>
  76. </div>
  77. </div>
  78. <div class="row">
  79. <div class="r-title"><label>模型标签</label></div>
  80. <div class="r-content">
  81. <el-input size="medium" :maxLength="255" v-model="state.label" placeholder="输入标签,多个标签用空格区分"></el-input>
  82. </div>
  83. </div>
  84. <div class="row" style="align-items:flex-start;">
  85. <div class="r-title"><label>模型描述</label></div>
  86. <div class="r-content">
  87. <el-input type="textarea" :maxLength="255" size="medium" v-model="state.description" :rows="3"
  88. placeholder="描述字数不超过255个字符">
  89. </el-input>
  90. </div>
  91. </div>
  92. <div class="row" style="margin-top:20px">
  93. <div class="r-title"><label></label></div>
  94. <div class="r-content">
  95. <el-button size="medium" class="green" @click="submit">保存模型</el-button>
  96. <el-button size="medium" @click="cancel">取消</el-button>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import { saveLocalModel, getModelInfoByName, modifyModel } from '~/apis/modules/modelmanage';
  105. // import { CLUSTERS, COMPUTER_RESOURCES, ACC_CARD_TYPE } from '~/const';
  106. import { getUrlSearchParams } from '~/utils';
  107. // import { formatDate } from 'element-ui/lib/utils/date-util';
  108. const REPO_NAME = location.pathname.split('/')[2];
  109. export default {
  110. data() {
  111. return {
  112. type: '0', // 1-修改,其它-新增
  113. loading: false,
  114. state: {
  115. type: 0,
  116. name: REPO_NAME + '_model_' + Math.random().toString(36).substr(2, 4),
  117. version: '0.0.1',
  118. engine: '0',
  119. label: '',
  120. description: '',
  121. },
  122. engineList: [{ k: '0', v: 'PyTorch' }, { k: '1', v: 'TensorFlow' }, { k: '2', v: 'MindSpore' }, { k: '4', v: 'PaddlePaddle' }, { k: '5', v: 'OneFlow' }, { k: '6', v: 'MXNet' }, { k: '3', v: 'Other' }],
  123. };
  124. },
  125. components: { /*QueueDialog*/ },
  126. methods: {
  127. submit() {
  128. console.log(this.state);
  129. if (!this.state.name) {
  130. this.$message({
  131. type: 'info',
  132. message: '请输入模型名称',
  133. });
  134. return;
  135. }
  136. const submintApi = this.type == '1' ? modifyModel : saveLocalModel;
  137. submintApi({
  138. repo: location.pathname.split('/').slice(0, 3).join('/'),
  139. ...this.state,
  140. }).then(res => {
  141. res = res.data;
  142. if (res && res.code == '0') {
  143. if (this.type == '1') {
  144. this.cancel();
  145. return;
  146. }
  147. const list = window.location.href.split('/');
  148. list.pop();
  149. list.push('create_local_model_tmpl2');
  150. window.location.href = list.join('/') + '?type=0name=' + this.state.name + '&id=' + res.id;
  151. } else {
  152. this.$message({
  153. type: 'error',
  154. message: this.type == '1' ? '模型修改失败' : '保存模型失败',
  155. });
  156. }
  157. }).catch(err => {
  158. console.log(err);
  159. });
  160. },
  161. cancel() {
  162. const list = window.location.href.split('/');
  163. list.pop();
  164. list.push('show_model');
  165. window.location.href = list.join('/');
  166. },
  167. },
  168. mounted() {
  169. const urlParams = getUrlSearchParams();
  170. if (urlParams.type == '1' && urlParams.name && urlParams.id) { // update
  171. this.type = urlParams.type;
  172. this.state.name = urlParams.name;
  173. this.state.id = urlParams.id;
  174. this.loading = true;
  175. getModelInfoByName({
  176. repo: location.pathname.split('/').slice(0, 3).join('/'),
  177. name: urlParams.name,
  178. id: urlParams.id
  179. }).then(res => {
  180. this.loading = false;
  181. const list = res.data;
  182. if (list && list.length) {
  183. const data = list[0];
  184. this.state.type = data.type;
  185. this.state.id = data.id;
  186. this.state.name = data.name;
  187. this.state.version = data.version;
  188. this.state.engine = data.engine.toString();
  189. this.state.label = data.label;
  190. this.state.description = data.description;
  191. }
  192. }).catch(err => {
  193. this.loading = false;
  194. console.log(err);
  195. this.cancel();
  196. });
  197. }
  198. },
  199. beforeDestroy() {
  200. },
  201. };
  202. </script>
  203. <style scoped lang="less">
  204. .header {
  205. height: 45px;
  206. border-color: rgb(212, 212, 213);
  207. border-width: 1px;
  208. border-style: solid;
  209. border-radius: 5px 5px 0px 0px;
  210. font-size: 14px;
  211. background: rgb(240, 240, 240);
  212. display: flex;
  213. align-items: center;
  214. .title {
  215. font-weight: 600;
  216. font-size: 16px;
  217. color: rgb(16, 16, 16);
  218. margin-left: 10px;
  219. }
  220. }
  221. .content {
  222. margin-top: -1px;
  223. border-color: rgb(212, 212, 213);
  224. border-width: 1px;
  225. border-style: solid;
  226. padding: 30px 0;
  227. border-top: none;
  228. .guide-c {
  229. display: flex;
  230. align-items: center;
  231. justify-content: center;
  232. margin-bottom: 20px;
  233. .step {
  234. display: flex;
  235. align-items: center;
  236. color: rgb(136, 136, 136);
  237. .num {
  238. border: 1px solid rgb(136, 136, 136);
  239. width: 34px;
  240. height: 34px;
  241. font-size: 24px;
  242. text-align: center;
  243. line-height: 34px;
  244. border-radius: 17px;
  245. margin-right: 8px;
  246. }
  247. .txt {
  248. font-weight: 600;
  249. }
  250. &.focused {
  251. color: rgb(22, 132, 252);
  252. .num {
  253. border-color: rgb(22, 132, 252);
  254. }
  255. }
  256. }
  257. .line {
  258. height: 2px;
  259. width: 50px;
  260. background-color: rgb(187, 187, 187);
  261. margin: 0 10px;
  262. }
  263. }
  264. .row-c {
  265. display: flex;
  266. align-items: center;
  267. justify-content: center;
  268. flex-direction: column;
  269. margin: 0 auto;
  270. width: 80%;
  271. .row {
  272. width: 100%;
  273. display: flex;
  274. align-items: center;
  275. margin: 8px 0;
  276. margin-left: -190px;
  277. .r-title {
  278. text-align: right;
  279. font-size: .92857143em;
  280. font-weight: 700;
  281. color: rgba(0, 0, 0, .87);
  282. width: 200px;
  283. margin-right: 28px;
  284. position: relative;
  285. .required {
  286. &::after {
  287. position: absolute;
  288. margin: -0.2em 0 0 0.2em;
  289. content: '*';
  290. color: #db2828;
  291. }
  292. }
  293. }
  294. .r-content {
  295. flex: 1;
  296. .cluster-type-btn {
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. border: 1px solid #DCDFE6;
  301. height: 36px;
  302. padding: 10px;
  303. cursor: pointer;
  304. border-radius: 4px;
  305. .icon {
  306. margin-right: 5px;
  307. }
  308. .txt {}
  309. &.focused {
  310. border-color: rgb(50, 145, 248);
  311. color: rgb(50, 145, 248);
  312. cursor: default;
  313. .icon {
  314. :not([stroke]) {
  315. fill: rgb(50, 145, 248);
  316. }
  317. }
  318. }
  319. }
  320. }
  321. }
  322. }
  323. }
  324. .input-disabled {
  325. /deep/ .el-input__inner {
  326. background-color: #f5f5f6 !important;
  327. color: #888888 !important;
  328. }
  329. }
  330. .el-select-dropdown__item.selected {
  331. color: rgba(0, 0, 0, .95);
  332. }
  333. /deep/ .el-button {
  334. background-color: #e0e1e2;
  335. color: rgba(0, 0, 0, .6);
  336. border-color: transparent;
  337. transition: opacity .1s ease, background-color .1s ease, color .1s ease, box-shadow .1s ease, background .1s ease, -webkit-box-shadow .1s ease;
  338. will-change: auto;
  339. -webkit-tap-highlight-color: transparent;
  340. &:hover {
  341. border-color: transparent;
  342. background-color: #cacbcd;
  343. color: rgba(0, 0, 0, .8);
  344. }
  345. &:focus {
  346. background-color: #cacbcd;
  347. color: rgba(0, 0, 0, .8);
  348. border-color: transparent;
  349. }
  350. &:active {
  351. background-color: #babbbc;
  352. color: rgba(0, 0, 0, .9);
  353. border-color: transparent;
  354. }
  355. &.green {
  356. background-color: #5bb973;
  357. color: #fff;
  358. &:hover {
  359. background-color: #16ab39;
  360. border-color: transparent;
  361. }
  362. &:focus {
  363. background-color: #0ea432;
  364. border-color: transparent;
  365. }
  366. &:active {
  367. background-color: #198f35;
  368. border-color: transparent;
  369. }
  370. }
  371. }
  372. /deep/ .el-select {
  373. .is-focus {
  374. .el-input__inner {
  375. border-color: #85b7d9;
  376. }
  377. }
  378. }
  379. /deep/ .el-input__inner {
  380. &:focus {
  381. border-color: #85b7d9;
  382. }
  383. }
  384. /deep/ .el-textarea__inner {
  385. &:focus {
  386. border-color: #85b7d9;
  387. }
  388. }
  389. </style>