Commit ae2068b5 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20221010-partition' into feat-20221012-environment

parents 21db42bf 27b686a0
...@@ -17,7 +17,6 @@ export type IQueueLi = { ...@@ -17,7 +17,6 @@ export type IQueueLi = {
coreNum: number; coreNum: number;
memory: number; memory: number;
total: number; total: number;
id: string;
partition: string; partition: string;
}; };
...@@ -34,7 +33,6 @@ type IQueueSelectProps = { ...@@ -34,7 +33,6 @@ type IQueueSelectProps = {
type IMemoryLi = { type IMemoryLi = {
memory: number; memory: number;
total: number; total: number;
id: string;
partition: string; partition: string;
}; };
...@@ -43,7 +41,6 @@ export type IShowCPULi = { ...@@ -43,7 +41,6 @@ export type IShowCPULi = {
picUrl: string; picUrl: string;
cpuName: string; cpuName: string;
coreNum: number; coreNum: number;
id: string;
partition: string; partition: string;
memoryList: Array<IMemoryLi>; memoryList: Array<IMemoryLi>;
}; };
...@@ -78,11 +75,10 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -78,11 +75,10 @@ const QueueSelect = (props: IQueueSelectProps) => {
setOpen(true); setOpen(true);
}; };
// 队列id、partition和前端展示的队列信息的映射关系 // 队列partition和前端展示的队列信息的映射关系
const idInfoMap = useMemo(() => { const idInfoMap = useMemo(() => {
return [ return [
...originalCpuList.map((item) => ({ ...originalCpuList.map((item) => ({
id: item.id,
partition: item.partition, partition: item.partition,
title: `${item.name}/${item.coreNum}${item.coreNum * item.memory}G/${ title: `${item.name}/${item.coreNum}${item.coreNum * item.memory}G/${
item.coreNum item.coreNum
...@@ -90,7 +86,6 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -90,7 +86,6 @@ const QueueSelect = (props: IQueueSelectProps) => {
total: item.total, total: item.total,
})), })),
...originalGpuList.map((item) => ({ ...originalGpuList.map((item) => ({
id: item.id,
partition: item.partition, partition: item.partition,
title: `${item.name}/${item.gpuNum}${item.coreNum}${item.memory}G/${item.gpuNum}总卡数`, title: `${item.name}/${item.gpuNum}${item.coreNum}${item.memory}G/${item.gpuNum}总卡数`,
total: item.total, total: item.total,
...@@ -98,41 +93,6 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -98,41 +93,6 @@ const QueueSelect = (props: IQueueSelectProps) => {
]; ];
}, [originalCpuList, originalGpuList]); }, [originalCpuList, originalGpuList]);
useEffect(() => {
let resultList: Array<IShowCPULi> = [];
originalCpuList.forEach((item) => {
const targetIndex = resultList.findIndex((resultLi) => {
return resultLi.name === item.name;
});
if (targetIndex === -1) {
resultList.push({
name: item.name,
picUrl: item.picUrl,
cpuName: item.cpuName,
coreNum: item.coreNum,
id: item.id,
partition: item.partition,
memoryList: [
{
memory: item.memory,
total: item.total,
id: item.id,
partition: item.partition,
},
],
});
} else {
resultList[targetIndex].memoryList.push({
memory: item.memory,
total: item.total,
id: item.id,
partition: item.partition,
});
}
});
setShowCpuList(resultList);
}, [originalCpuList]);
const cpuHeadCells = [ const cpuHeadCells = [
{ {
id: "type", id: "type",
...@@ -174,6 +134,57 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -174,6 +134,57 @@ const QueueSelect = (props: IQueueSelectProps) => {
}, },
]; ];
// 有初始值的话显示初始值
useEffect(() => {
let resultList: Array<IShowCPULi> = [];
originalCpuList.forEach((item) => {
const targetIndex = resultList.findIndex((resultLi) => {
return resultLi.name === item.name;
});
if (targetIndex === -1) {
resultList.push({
name: item.name,
picUrl: item.picUrl,
cpuName: item.cpuName,
coreNum: item.coreNum,
partition: item.partition,
memoryList: [
{
memory: item.memory,
total: item.total,
partition: item.partition,
},
],
});
} else {
resultList[targetIndex].memoryList.push({
memory: item.memory,
total: item.total,
partition: item.partition,
});
}
});
if (open && value) {
const cpuActivePartitionIndex = originalCpuList.findIndex(
(li) => li.partition === value
);
let cpuActivePartitionName = "";
if (cpuActivePartitionIndex !== -1) {
cpuActivePartitionName = originalCpuList[cpuActivePartitionIndex].name;
}
if (cpuActivePartitionIndex !== -1) {
resultList.forEach((li, index) => {
if (li.name === cpuActivePartitionName) {
resultList[index].partition = value;
}
});
}
setActivePartition(value);
}
setShowCpuList(resultList);
// eslint-disable-next-line
}, [open, value, originalCpuList]);
const renderType = (item: IShowCPULi) => { const renderType = (item: IShowCPULi) => {
return ( return (
<div className={style.cpuType}> <div className={style.cpuType}>
...@@ -223,6 +234,9 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -223,6 +234,9 @@ const QueueSelect = (props: IQueueSelectProps) => {
}))} }))}
hasTriangle={true} hasTriangle={true}
setValue={setMemory} setValue={setMemory}
sx={{
zIndex: 1601,
}}
> >
<span className={style.cpuMemory}> <span className={style.cpuMemory}>
{ {
......
// 单选下拉框, 是input还是text还是其他由children决定 // 单选下拉框, 是input还是text还是其他由children决定
import * as React from "react"; import * as React from "react";
import Menu from "@mui/material/Menu"; import Menu, { MenuProps } from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import CheckIcon from "@mui/icons-material/Check"; import CheckIcon from "@mui/icons-material/Check";
import { ThemeProvider, createTheme } from "@mui/material/styles"; import { ThemeProvider, createTheme } from "@mui/material/styles";
...@@ -12,13 +12,13 @@ type IOption = { ...@@ -12,13 +12,13 @@ type IOption = {
value: string; value: string;
}; };
type IMyMenuProps = { interface IMyMenuProps extends Omit<MenuProps, "open"> {
children: React.ReactNode; children: React.ReactNode;
options: Array<IOption>; options: Array<IOption>;
value: string; value: string;
setValue?: any; setValue?: any;
hasTriangle?: boolean; hasTriangle?: boolean;
}; }
const theme = createTheme({ const theme = createTheme({
components: { components: {
...@@ -65,7 +65,14 @@ const theme = createTheme({ ...@@ -65,7 +65,14 @@ const theme = createTheme({
}); });
const MyMenu = (props: IMyMenuProps) => { const MyMenu = (props: IMyMenuProps) => {
const { children, options, value, setValue, hasTriangle = false } = props; const {
children,
options,
value,
setValue,
hasTriangle = false,
...other
} = props;
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLDivElement>) => { const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
...@@ -112,6 +119,7 @@ const MyMenu = (props: IMyMenuProps) => { ...@@ -112,6 +119,7 @@ const MyMenu = (props: IMyMenuProps) => {
MenuListProps={{ MenuListProps={{
"aria-labelledby": "basic-button", "aria-labelledby": "basic-button",
}} }}
{...other}
> >
{options.map((option, index) => { {options.map((option, index) => {
return ( return (
......
import { useMemo, useCallback, useEffect, useState } from "react"; import { useMemo, useCallback, useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import MyProgress from "@/components/mui/MyProgress"; import MyProgress from "@/components/mui/MyProgress";
import { getDatasetPath } from "../../ProjectJobDetail/utils";
import style from "./index.module.css"; import style from "./index.module.css";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { toJS } from "mobx"; import { toJS } from "mobx";
...@@ -27,7 +28,7 @@ type TaskCardProps = { ...@@ -27,7 +28,7 @@ type TaskCardProps = {
outputs: Array<any>; outputs: Array<any>;
}; };
const TaskCard = (props: TaskCardProps) => { const TaskCard = observer((props: TaskCardProps) => {
const { const {
id, id,
name, name,
...@@ -66,15 +67,17 @@ const TaskCard = (props: TaskCardProps) => { ...@@ -66,15 +67,17 @@ const TaskCard = (props: TaskCardProps) => {
// 结果文件跳转 // 结果文件跳转
const goToProjectData = (info: any) => { const goToProjectData = (info: any) => {
let { path = "", type = "" } = info; let { path = "", type = "" } = info;
const lastIndex = path.lastIndexOf("/"); if (type === "file") {
// /projectData const lastIndex = path.lastIndexOf("/");
// dataType if (lastIndex !== -1) {
if (lastIndex !== -1) { path = path.slice(0, lastIndex);
path = path.slice(0, lastIndex); }
path = path.slice(12);
} else {
path = getDatasetPath(path);
} }
path = path.slice(12);
navigate(`/product/${productId || "cadd"}/projectData`, { navigate(`/product/${productId || "cadd"}/projectData`, {
state: { pathName: path || "/", dataType: type }, state: { pathName: path, dataType: type },
}); });
}; };
// 跳转详情页 // 跳转详情页
...@@ -247,6 +250,6 @@ const TaskCard = (props: TaskCardProps) => { ...@@ -247,6 +250,6 @@ const TaskCard = (props: TaskCardProps) => {
</div> </div>
</div> </div>
); );
}; });
export default TaskCard; export default TaskCard;
...@@ -93,8 +93,10 @@ const ProjectSubmitWork = observer(() => { ...@@ -93,8 +93,10 @@ const ProjectSubmitWork = observer(() => {
: String(parameter.defaultValue); : String(parameter.defaultValue);
} else if ((parameter.domType || "").toLowerCase() === "radio") { } else if ((parameter.domType || "").toLowerCase() === "radio") {
value = false; value = false;
} else if ((parameter.domType || "").toLowerCase() === "partition") {
value = false;
} else { } else {
value = ""; value = parameter.defaultValue;
} }
parameter.value = value; parameter.value = value;
}); });
......
...@@ -2,10 +2,8 @@ import _ from "lodash"; ...@@ -2,10 +2,8 @@ import _ from "lodash";
import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import classNames from "classnames"; import classNames from "classnames";
import QueueSelect from "@/components/BusinessComponents/QueueSelect";
import useMyRequest from "@/hooks/useMyRequest";
import { getHardwreList } from "@/api/project_api";
import { IQueueLi } from "@/components/BusinessComponents/QueueSelect"; import { IQueueLi } from "@/components/BusinessComponents/QueueSelect";
import QueueSelect from "@/components/BusinessComponents/QueueSelect";
import { import {
ITask, ITask,
IParameter, IParameter,
...@@ -32,10 +30,17 @@ type IParameterSettingProps = { ...@@ -32,10 +30,17 @@ type IParameterSettingProps = {
templateConfigInfo: ITask[]; templateConfigInfo: ITask[];
taskId: string; taskId: string;
setTemplateConfigInfo: any; setTemplateConfigInfo: any;
zoneId: string; cpuList: Array<IQueueLi>;
gpuList: Array<IQueueLi>;
}; };
const ParameterSetting = (props: IParameterSettingProps) => { const ParameterSetting = (props: IParameterSettingProps) => {
const { templateConfigInfo, setTemplateConfigInfo, taskId, zoneId } = props; // 算子大数组 const {
templateConfigInfo,
setTemplateConfigInfo,
taskId,
cpuList,
gpuList,
} = props; // 算子大数组
const [isShowAllDese, setIsShowAllDese] = useState(false); // 是否展示全部描述 const [isShowAllDese, setIsShowAllDese] = useState(false); // 是否展示全部描述
const [fileSelectOpen, setFileSelectOpen] = useState(false); // 选择输出路径的弹窗显示控制 const [fileSelectOpen, setFileSelectOpen] = useState(false); // 选择输出路径的弹窗显示控制
const [fileSelectType, setFileSelectType] = useState<FileSelectType>("path"); const [fileSelectType, setFileSelectType] = useState<FileSelectType>("path");
...@@ -43,31 +48,6 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -43,31 +48,6 @@ const ParameterSetting = (props: IParameterSettingProps) => {
const resizeRef = useRef<HTMLDivElement>(null); const resizeRef = useRef<HTMLDivElement>(null);
const [activeParamsTab, setActiveParamsTab] = useState<string>(""); const [activeParamsTab, setActiveParamsTab] = useState<string>("");
const [cpuList, setCpuList] = useState<Array<IQueueLi>>([]);
const [gpuList, setGpuList] = useState<Array<IQueueLi>>([]);
const { run: getHardwreListFn } = useMyRequest(getHardwreList, {
onSuccess: (res, params) => {
if (params[0].computeType === "CPU") {
setCpuList(res.data);
} else {
setGpuList(res.data);
}
},
});
useEffect(() => {
getHardwreListFn({
zoneId,
computeType: "CPU",
});
}, [getHardwreListFn, zoneId]);
useEffect(() => {
getHardwreListFn({
zoneId,
computeType: "GPU",
});
}, [getHardwreListFn, zoneId]);
const size = useSize(resizeRef); const size = useSize(resizeRef);
// 文件夹路线选择器弹窗 // 文件夹路线选择器弹窗
......
...@@ -11,7 +11,9 @@ import _ from "lodash"; ...@@ -11,7 +11,9 @@ import _ from "lodash";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { toJS } from "mobx"; import { toJS } from "mobx";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import useMyRequest from "@/hooks/useMyRequest";
import { getHardwreList } from "@/api/project_api";
import { IQueueLi } from "@/components/BusinessComponents/QueueSelect";
import MyPopconfirm from "@/components/mui/MyPopconfirm"; import MyPopconfirm from "@/components/mui/MyPopconfirm";
import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle"; import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle";
import MyButton from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
...@@ -22,7 +24,6 @@ import { useMessage } from "@/components/MySnackbar"; ...@@ -22,7 +24,6 @@ import { useMessage } from "@/components/MySnackbar";
import { ITask } from "../Project/ProjectSubmitWork/interface"; import { ITask } from "../Project/ProjectSubmitWork/interface";
import { fetchTemplateConfigInfo } from "@/api/project_api"; import { fetchTemplateConfigInfo } from "@/api/project_api";
import { getCustomTemplateParameterCheckResult } from "./util"; import { getCustomTemplateParameterCheckResult } from "./util";
import useMyRequest from "@/hooks/useMyRequest";
import CustomOperator from "../CustomOperator"; import CustomOperator from "../CustomOperator";
import SaveCustomTemplate from "./components/SaveCustomTemplate"; import SaveCustomTemplate from "./components/SaveCustomTemplate";
import AddIcon from "@mui/icons-material/Add"; import AddIcon from "@mui/icons-material/Add";
...@@ -66,6 +67,32 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -66,6 +67,32 @@ const WorkFlowEdit = observer((props: IProps) => {
// 确认弹窗标题 // 确认弹窗标题
"返回后,当前页面已填写内容将不保存,确认返回吗?" "返回后,当前页面已填写内容将不保存,确认返回吗?"
); );
const [cpuList, setCpuList] = useState<Array<IQueueLi>>([]);
const [gpuList, setGpuList] = useState<Array<IQueueLi>>([]);
const { run: getHardwreListFn } = useMyRequest(getHardwreList, {
onSuccess: (res, params) => {
if (params[0].computeType === "CPU") {
setCpuList(res.data);
} else {
setGpuList(res.data);
}
},
});
useEffect(() => {
zoneId &&
getHardwreListFn({
zoneId,
computeType: "CPU",
});
}, [getHardwreListFn, zoneId]);
useEffect(() => {
zoneId &&
getHardwreListFn({
zoneId,
computeType: "GPU",
});
}, [getHardwreListFn, zoneId]);
// 是否要监听删除时间 // 是否要监听删除时间
const listenState = useMemo(() => { const listenState = useMemo(() => {
...@@ -247,7 +274,8 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -247,7 +274,8 @@ const WorkFlowEdit = observer((props: IProps) => {
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setTemplateConfigInfo={setTemplateConfigInfo} setTemplateConfigInfo={setTemplateConfigInfo}
taskId={selectTaskId || ""} taskId={selectTaskId || ""}
zoneId={zoneId as string} cpuList={cpuList}
gpuList={gpuList}
/> />
)} )}
<div <div
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment