Skip to content

Commit 2594658

Browse files
authored
[Utilization] Fix bugs and context (#6292)
fix the frame to fit chart, and modify content for sections
1 parent 27cb511 commit 2594658

File tree

8 files changed

+63
-40
lines changed

8 files changed

+63
-40
lines changed

torchci/components/charts/line_rect_chart/component/RenderLinePickerOptions.tsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ChartCheckboxGroups from "./helpers/ChartCheckboxGroups";
88
import { CheckboxItem } from "./helpers/CheckboxGroup";
99
import DropList from "./helpers/DropList";
1010
import styles from "./RenderLineChartComponents.module.css";
11+
const defaultCategory = "all";
1112

1213
const RenderLinePickerOptions = ({
1314
lines,
@@ -18,25 +19,30 @@ const RenderLinePickerOptions = ({
1819
setLines: (line: any[]) => void;
1920
lineFilterConfig: PickerConfig[];
2021
}) => {
21-
const [category, setCategory] = useState<string>("");
22+
const [category, setCategory] = useState<string>(defaultCategory);
2223
const [options, setOptions] = useState<any>([]);
2324
const [groups, setGroups] = useState<any>([]);
2425

2526
useEffect(() => {
27+
renderOptions();
2628
render();
2729
}, [lines, lineFilterConfig]);
2830

29-
function render() {
31+
function renderOptions() {
3032
let options = lineFilterConfig.map((config) => {
3133
return { value: config.category, name: config.category };
3234
});
3335
setOptions(options);
36+
}
3437

38+
function render() {
3539
const config = lineFilterConfig.find((item) => item.category == category);
3640
if (!config) {
3741
setGroups([]);
3842
return;
3943
}
44+
45+
// render checkboxes
4046
const res = config.types.map((type) => {
4147
return {
4248
parentName: type.name,
@@ -46,16 +52,28 @@ const RenderLinePickerOptions = ({
4652
setGroups(res);
4753
}
4854

49-
function resetLines() {
55+
function resetLines(category: string) {
56+
// clear all lines
5057
const newLines = lines.map((line) => {
5158
line.hidden = true;
5259
return line;
5360
});
61+
// show all lines in the selected category
62+
const config = lineFilterConfig.find((item) => item.category == category);
63+
if (config) {
64+
config.types.forEach((type) => {
65+
newLines.forEach((line) => {
66+
if (containsAllSubstrings(line.id, type.tags)) {
67+
line.hidden = false;
68+
}
69+
});
70+
});
71+
}
5472
setLines(newLines);
5573
}
5674

5775
useEffect(() => {
58-
resetLines();
76+
resetLines(category);
5977
render();
6078
}, [category]);
6179

@@ -95,7 +113,11 @@ const RenderLinePickerOptions = ({
95113
{options.length > 0 && (
96114
<div className={styles.rowFlexCenter}>
97115
<div>Group by:</div>
98-
<DropList onChange={changeLineCateory} options={options}></DropList>
116+
<DropList
117+
onChange={changeLineCateory}
118+
options={options}
119+
defaultValue={defaultCategory}
120+
></DropList>
99121
</div>
100122
)}
101123
{groups.length > 0 && (

torchci/components/charts/line_rect_chart/component/helpers/DropList.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ import { useState } from "react";
99
export default function DropList({
1010
onChange,
1111
options,
12+
defaultValue,
1213
}: {
1314
onChange: (value: string) => void;
1415
options: { value: string; name: string }[];
16+
defaultValue?: string;
1517
}) {
16-
const [value, setValue] = useState<string>("unselect");
18+
const [value, setValue] = useState<string>(defaultValue ?? "unselect");
1719

1820
const handleChange = (event: SelectChangeEvent) => {
1921
setValue(event.target.value);
2022
onChange(event.target.value);
2123
};
24+
2225
return (
2326
<div>
2427
<FormControl sx={{ m: 1, minWidth: 80 }}>
2528
<Select value={value} onChange={handleChange} autoWidth>
26-
<MenuItem value={"unselect"}>{"unselect"}</MenuItem>
29+
{defaultValue ?? <MenuItem value={"unselect"}>{"unselect"}</MenuItem>}
2730
{options.map((option, idx) => {
2831
return (
2932
<MenuItem key={idx} value={option.value}>

torchci/components/utilization/UtilizationPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const UtilizationPage = ({
9696
<Divider />
9797
<LineRectChart
9898
inputLines={timeSeriesList}
99-
chartWidth={1200}
99+
chartWidth={1400}
100100
disableLineTooltip={false}
101101
disableRect={true}
102102
lineFilterConfig={lineFilters}

torchci/components/utilization/components/TestSectionView/SingleTestView.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { styled } from "@mui/material";
1+
import { Divider, styled } from "@mui/material";
22
import LineRectChart from "components/charts/line_rect_chart/LineRectChart";
33
import {
44
formatSeconds,
@@ -28,7 +28,6 @@ const GraphGroupSection = styled("div")({
2828
const SingleGraphSection = styled("div")({
2929
margin: "5px",
3030
padding: "10px",
31-
border: "1px solid #ccc",
3231
});
3332

3433
export const SingleTestView = ({
@@ -71,7 +70,8 @@ export const SingleTestView = ({
7170

7271
return (
7372
<div>
74-
<h1>Selected Test Details</h1>
73+
<h1>Selected Test Segment Details</h1>
74+
<Divider />
7575
<InfoCard>
7676
<InfoSection>
7777
<InfoTitle>Test Name:</InfoTitle>
@@ -105,7 +105,7 @@ export const SingleTestView = ({
105105
{testTimeSeries && (
106106
<LineRectChart
107107
inputLines={testTimeSeries}
108-
chartWidth={1200}
108+
chartWidth={1000}
109109
disableLineTooltip={false}
110110
disableRect={true}
111111
lineFilterConfig={lineFilters}
@@ -116,7 +116,7 @@ export const SingleTestView = ({
116116
<div> Location of the test: </div>
117117
<LineRectChart
118118
inputLines={timeSeriesList}
119-
chartWidth={800}
119+
chartWidth={700}
120120
rects={[testSegment]}
121121
disableLineTooltip={true}
122122
disableRect={false}

torchci/components/utilization/components/TestSectionView/TestSectionView.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Paper } from "@mui/material";
21
import { getDuration } from "components/utilization/helper";
32
import { Segment } from "lib/utilization/types";
43
import { useEffect, useState } from "react";
@@ -34,9 +33,9 @@ export const TestSectionView = ({
3433
<h3>Detected python test details</h3>
3534
<Divider />
3635
<div>
37-
<InfoTitle>Tests ({renderSegments.length}) </InfoTitle>
36+
<InfoTitle>Potential Python Tests ({renderSegments.length}) </InfoTitle>
3837
<Description>
39-
{`We detected (${renderSegments.length}) tests on PYTHON_CMD level`}
38+
{`We detected (${renderSegments.length}) segments that are potentially tests on PYTHON_CMD level`}
4039
</Description>
4140
{renderSegments.length > 0 && timeSeriesList.length > 0 && (
4241
<ToggleTestsGroup
@@ -47,12 +46,12 @@ export const TestSectionView = ({
4746
)}
4847
<div>
4948
{pickedSegment ? (
50-
<Paper>
49+
<div>
5150
<SingleTestView
5251
testSegment={pickedSegment}
5352
timeSeriesList={timeSeriesList}
5453
/>
55-
</Paper>
54+
</div>
5655
) : (
5756
<Blank></Blank>
5857
)}

torchci/components/utilization/components/TestSectionView/ToggleTestsGroup.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import { useState } from "react";
1414
import { RankTestView } from "./RankTestView/RankTestView";
1515

1616
const toggleItems = [
17-
{
18-
name: "list view",
19-
value: "list",
20-
},
2117
{
2218
name: "chart view",
2319
value: "chart",
2420
},
21+
{
22+
name: "list view",
23+
value: "list",
24+
},
2525
{
2626
name: "rank view",
2727
value: "rank",
@@ -35,7 +35,7 @@ export const TestList = styled(Paper)({
3535
overflow: "auto",
3636
backgroundColor: "#f5f5f5",
3737
});
38-
const defaultTestViewValue = "list";
38+
const defaultTestViewValue = "chart";
3939

4040
export const ToggleTestsGroup = ({
4141
pickSegment,
@@ -81,7 +81,7 @@ export const ToggleTestsGroup = ({
8181
return (
8282
<div>
8383
<ToggleGroup
84-
defaultValue={"list"}
84+
defaultValue={defaultTestViewValue}
8585
items={toggleItems}
8686
onChange={handleToggleTestView}
8787
/>
@@ -118,18 +118,16 @@ export const ToggleTestsGroup = ({
118118
</TestList>
119119
</div>
120120
<div>
121-
{showSegmentLocation && (
122-
<div>
123-
<div> Location of the test: </div>
124-
<LineRectChart
125-
inputLines={timeSeriesList}
126-
chartWidth={800}
127-
rects={[showSegmentLocation]}
128-
disableLineTooltip={true}
129-
disableRect={false}
130-
></LineRectChart>
131-
</div>
132-
)}
121+
<div>
122+
<div> Location of the test: </div>
123+
<LineRectChart
124+
inputLines={timeSeriesList}
125+
chartWidth={800}
126+
rects={showSegmentLocation ? [showSegmentLocation] : []}
127+
disableLineTooltip={true}
128+
disableRect={false}
129+
></LineRectChart>
130+
</div>
133131
</div>
134132
</FlexSection>
135133
)}

torchci/components/utilization/components/UtilizationJobSummary/UtilizationJobSummary.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ const JobUtilizationSummary = ({
6969
const duration = getDurationMetrics(
7070
new Date(metadata.start_at),
7171
new Date(metadata.end_at),
72-
"Job Duration",
73-
"job|duration"
72+
"Test Duration",
73+
"duration"
7474
);
7575
const numeric_metrics = getMetadataStats(metadata);
7676
const mdm = [duration, ...numeric_metrics];
@@ -106,7 +106,7 @@ const JobUtilizationSummary = ({
106106
</MetadataGroupSection>
107107
</ContainerSection>
108108
<StatsTable>
109-
<SectionTitle> Job Metrics Summary Table</SectionTitle>
109+
<SectionTitle> Test Job Metrics Summary Table</SectionTitle>
110110
<UtilizationStatsTable data={tableData} />
111111
</StatsTable>
112112
</div>

torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import LoadingPage from "components/LoadingPage";
12
import { UtilizationPage } from "components/utilization/UtilizationPage";
23
import { fetcherHandleError } from "lib/GeneralUtils";
34
import { UtilizationAPIResponse } from "lib/utilization/types";
@@ -22,7 +23,7 @@ const Utilization = () => {
2223
}
2324

2425
if (!data) {
25-
return <div>loading...</div>;
26+
return <LoadingPage />;
2627
}
2728

2829
return (

0 commit comments

Comments
 (0)