Skip to content

Commit 47dd6f1

Browse files
Pablo Carmonastarpit
authored andcommitted
Create and add memory utilization chart below gpu utilization chart. Add labels to it chart.
1 parent 9b4fd18 commit 47dd6f1

File tree

3 files changed

+62
-20
lines changed

3 files changed

+62
-20
lines changed

plugins/plugin-codeflare/src/components/GPUChart.tsx

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import React from "react"
18-
import { Chart, ChartAxis, ChartGroup, ChartArea } from "@patternfly/react-charts"
18+
import { Chart, ChartAxis, ChartArea } from "@patternfly/react-charts"
1919
import { Log } from "../types"
2020

2121
import "../../web/scss/components/Dashboard/Charts.scss"
@@ -42,11 +42,15 @@ const axisStyle = { tickLabels: { fontSize: 9 } }
4242
const yTickValues = [0, 25, 50, 75, 100]
4343
const yTickLabels = yTickValues.map((_) => `${_}%`)
4444

45+
const styles = {
46+
memory: { data: { fill: "var(--color-chart-0)" } },
47+
gpu: { data: { fill: "var(--color-chart-1)" } },
48+
}
49+
4550
const GPUChart = (props: Props) => {
4651
const { logs } = props
47-
console.log(generateXValues(logs))
4852
return (
49-
<div style={{ height: "auto", width: "100%" }}>
53+
<div style={{ height: "auto", width: "100%", display: "flex", flexDirection: "column" }}>
5054
<Chart
5155
ariaTitle="GPU Utilization"
5256
ariaDesc="Chart showing GPU utilization over time"
@@ -56,28 +60,72 @@ const GPUChart = (props: Props) => {
5660
minDomain={{ y: 0 }}
5761
padding={{
5862
bottom: 25,
59-
left: 50,
63+
left: 60,
6064
right: 5,
6165
top: 10,
6266
}}
6367
>
64-
<ChartAxis dependentAxis showGrid style={axisStyle} tickValues={yTickValues} tickFormat={yTickLabels} />
68+
<ChartAxis
69+
label="GPU"
70+
dependentAxis
71+
showGrid
72+
style={axisStyle}
73+
tickValues={yTickValues}
74+
tickFormat={yTickLabels}
75+
/>
6576
<ChartAxis
6677
scale="time"
6778
style={axisStyle}
6879
tickValues={generateXValues(logs)}
6980
tickFormat={generateXFormat(logs)}
7081
tickCount={generateXFormat(logs).length}
7182
/>
72-
<ChartGroup>
73-
<ChartArea
74-
data={logs.map((log) => ({
75-
name: log.gpuType,
76-
x: log.timestamp,
77-
y: log.utilizationGPU,
78-
}))}
79-
/>
80-
</ChartGroup>
83+
<ChartArea
84+
style={styles.gpu}
85+
data={logs.map((log) => ({
86+
name: log.gpuType,
87+
x: log.timestamp,
88+
y: log.utilizationGPU,
89+
}))}
90+
/>
91+
</Chart>
92+
<Chart
93+
ariaTitle="GPU Memory Utilization"
94+
ariaDesc="Chart showing GPU memory utilization over time"
95+
height={135}
96+
width={1000}
97+
maxDomain={{ y: 100 }}
98+
minDomain={{ y: 0 }}
99+
padding={{
100+
bottom: 25,
101+
left: 60,
102+
right: 5,
103+
top: 10,
104+
}}
105+
>
106+
<ChartAxis
107+
label="Memory"
108+
dependentAxis
109+
showGrid
110+
style={axisStyle}
111+
tickValues={yTickValues}
112+
tickFormat={yTickLabels}
113+
/>
114+
<ChartAxis
115+
scale="time"
116+
style={axisStyle}
117+
tickValues={generateXValues(logs)}
118+
tickFormat={generateXFormat(logs)}
119+
tickCount={generateXFormat(logs).length}
120+
/>
121+
<ChartArea
122+
style={styles.memory}
123+
data={logs.map((log) => ({
124+
name: log.gpuType,
125+
x: log.timestamp,
126+
y: log.utilizationMemory,
127+
}))}
128+
/>
81129
</Chart>
82130
</div>
83131
)

plugins/plugin-codeflare/src/controller/chart.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ async function chart(args: Arguments) {
5757
const objLogs = formattedLogs.map((logLine) => formatLogObject(logLine))
5858
const React = await import("react")
5959
const GPUChart = await import("../components/GPUChart")
60-
console.log(objLogs)
6160

6261
return {
6362
react: React.createElement(GPUChart.default, { logs: objLogs }),

plugins/plugin-codeflare/web/scss/components/Dashboard/Charts.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616

1717
.pf-c-chart {
18-
path {
19-
fill: var(--color-latency-1) !important;
20-
stroke: var(--color-latency-1) !important;
21-
}
22-
2318
line {
2419
stroke: var(--color-base01) !important;
2520
}

0 commit comments

Comments
 (0)