Skip to content

Commit

Permalink
feat(ui-tasks): add launcher metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Mar 1, 2024
1 parent 7531dfc commit cbb27b9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
4 changes: 3 additions & 1 deletion webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@
"study.postProcessing": "Post processing",
"study.timeLimit": "Time limit (h)",
"study.nbCpu": "Number of cores",
"study.clusterLoad": "Cluster load",
"study.allocatedCpuRate": "CPU usage",
"study.clusterLoadRate": "Cluster load",
"study.nbQueuedJobs": "Pending jobs",
"study.synthesis": "Synthesis",
"study.level": "Level",
"study.years": "Years",
Expand Down
4 changes: 3 additions & 1 deletion webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@
"study.postProcessing": "Post-traitement",
"study.timeLimit": "Limite de temps (h)",
"study.nbCpu": "Nombre de coeurs",
"study.clusterLoad": "Charge du cluster",
"study.allocatedCpuRate": "Utilisation CPU",
"study.clusterLoadRate": "Charge du cluster",
"study.nbQueuedJobs": "Tâches en attente",
"study.synthesis": "Synthèse",
"study.level": "Niveau",
"study.years": "Années",
Expand Down
55 changes: 38 additions & 17 deletions webapp/src/components/App/Tasks/JobTableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Checkbox,
FormControlLabel,
Typography,
Skeleton,
} from "@mui/material";
import { useTranslation } from "react-i18next";
import RefreshIcon from "@mui/icons-material/Refresh";
Expand All @@ -27,8 +28,9 @@ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
import { grey } from "@mui/material/colors";
import { TaskView, TaskType } from "../../../common/types";
import usePromiseWithSnackbarError from "../../../hooks/usePromiseWithSnackbarError";
import { getLauncherLoad } from "../../../services/api/study";
import { getLauncherMetrics } from "../../../services/api/study";
import LinearProgressWithLabel from "../../common/LinearProgressWithLabel";
import UsePromiseCond from "../../common/utils/UsePromiseCond";

interface PropType {
content: TaskView[];
Expand All @@ -44,11 +46,13 @@ function JobTableView(props: PropType) {
useState<boolean>(false);
const [currentContent, setCurrentContent] = useState<TaskView[]>(content);

const { data: load, reload: reloadLauncherLoad } =
usePromiseWithSnackbarError(() => getLauncherLoad(), {
const laucherMetrics = usePromiseWithSnackbarError(
() => getLauncherMetrics(),
{
errorMessage: t("study.error.launchLoad"),
deps: [],
});
},
);

const applyFilter = useCallback(
(taskList: TaskView[]) => {
Expand Down Expand Up @@ -109,29 +113,46 @@ function JobTableView(props: PropType) {
>
<Box
sx={{
width: "30%",
width: "60%",
display: "flex",
justifyContent: "flex-start",
alignItems: "flex-end",
alignContent: "center",
alignSelf: "center",
gap: 1,
}}
>
<Typography sx={{ mr: 2 }}>{t("study.clusterLoad")}</Typography>
{load && (
<LinearProgressWithLabel
indicator={load.slurm * 100}
size="60%"
tooltip={t("study.clusterLoad")}
gradiant
/>
)}
<UsePromiseCond
response={laucherMetrics}
ifResolved={(data) => (
<>
<Typography>{t("study.allocatedCpuRate")}</Typography>
<LinearProgressWithLabel
indicator={data.allocatedCpuRate}
size="20%"
tooltip={t("study.allocatedCpuRate")}
gradiant
/>
<Typography>{t("study.clusterLoadRate")}</Typography>
<LinearProgressWithLabel
indicator={data.clusterLoadRate}
size="20%"
tooltip={t("study.clusterLoadRate")}
gradiant
/>
<Typography>
{t("study.nbQueuedJobs")}: {data.nbQueuedJobs}
</Typography>
</>
)}
ifPending={() => <Skeleton width={300} />}
/>
</Box>
<Box display="flex" alignItems="center">
<Tooltip title={t("tasks.refresh") as string} sx={{ mr: 4 }}>
<Button
color="primary"
onClick={() => {
refresh();
reloadLauncherLoad();
laucherMetrics.reload();
}}
variant="outlined"
>
Expand Down
10 changes: 6 additions & 4 deletions webapp/src/services/api/study.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@ export const launchStudy = async (
return res.data;
};

interface LauncherLoadDTO {
slurm: number;
local: number;
interface LauncherMetrics {
allocatedCpuRate: number;
clusterLoadRate: number;
nbQueuedJobs: number;
status: string;
}

export const getLauncherVersions = async (): Promise<string[]> => {
Expand All @@ -302,7 +304,7 @@ export const getLauncherCores = async (): Promise<Record<string, number>> => {
return res.data;
};

export const getLauncherLoad = async (): Promise<LauncherLoadDTO> => {
export const getLauncherMetrics = async (): Promise<LauncherMetrics> => {
const res = await client.get("/v1/launcher/load");
return res.data;
};
Expand Down

0 comments on commit cbb27b9

Please sign in to comment.