-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resource-catalog): add queue metrics component
- Loading branch information
Showing
9 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"queueMetrics": [ | ||
{ | ||
"resourceId": 1, | ||
"name": "Bridges-2 Regular Memory", | ||
"resourceRepositoryKey": 2900, | ||
"waitTime": 5.909166, | ||
"wallTime": 2.007403, | ||
"expansionFactor": 5.3611, | ||
"order": 1 | ||
}, | ||
{ | ||
"resourceId": 2, | ||
"name": "Bridges-2 Extreme Memory", | ||
"resourceRepositoryKey": 2903, | ||
"waitTime": 5.233983, | ||
"wallTime": 6.61043, | ||
"expansionFactor": 1.7911, | ||
"order": 2 | ||
}, | ||
{ | ||
"resourceId": 3, | ||
"name": "Bridges-2 GPU", | ||
"resourceRepositoryKey": 2902, | ||
"waitTime": 19.670669, | ||
"wallTime": 2.072165, | ||
"expansionFactor": 10.4929, | ||
"order": 3 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.info-tip { | ||
background-color: transparent; | ||
border: 0 none transparent; | ||
} | ||
.tippy-box[data-theme~="access"] { | ||
background-color: var(--teal-700); | ||
border-radius: 0; | ||
color: white; | ||
font-weight: 400; | ||
padding: 5px; | ||
} | ||
.tippy-box[data-theme~="access"][data-placement^="top"] > .tippy-arrow::before { | ||
border-top-color: var(--teal-700); | ||
} | ||
.tippy-box[data-theme~="access"][data-placement^="bottom"] | ||
> .tippy-arrow::before { | ||
border-bottom-color: var(--teal-700); | ||
} | ||
.tippy-box[data-theme~="access"][data-placement^="left"] | ||
> .tippy-arrow::before { | ||
border-left-color: var(--teal-700); | ||
} | ||
.tippy-box[data-theme~="access"][data-placement^="right"] | ||
> .tippy-arrow::before { | ||
border-right-color: var(--teal-700); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useLayoutEffect, useRef } from "preact/hooks"; | ||
import tippy from "tippy.js"; | ||
|
||
import Icon from "./icon"; | ||
|
||
export default function InfoTip({ | ||
color = "var(--contrast-6)", | ||
icon = "info-circle-fill", | ||
tooltip, | ||
}) { | ||
const trigger = useRef(null); | ||
useLayoutEffect(() => { | ||
if (trigger.current) | ||
tippy(trigger.current, { content: tooltip, theme: "access" }); | ||
}, [trigger.current]); | ||
|
||
return ( | ||
<button class="info-tip" style={{ color }} ref={trigger}> | ||
<Icon name={icon} /> | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useJSON } from "./utils"; | ||
|
||
import Grid from "./grid"; | ||
import Icon from "./icon"; | ||
import InfoTip from "./info-tip"; | ||
|
||
const formatTime = (value) => { | ||
const hours = Math.floor(value); | ||
const minutes = Math.floor((value - hours) * 60); | ||
const seconds = Math.round((value - hours) * 3600 - minutes * 60); | ||
return [hours, minutes, seconds] | ||
.map((value) => value.toString().padStart(2, "0")) | ||
.join(":"); | ||
}; | ||
|
||
const formatHeaderTip = (content) => (value) => { | ||
return ( | ||
<> | ||
<span>{value}</span> <InfoTip tooltip={content} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default function ResourceGroupQueueMetrics({ | ||
baseUri, | ||
resourceGroupId, | ||
}) { | ||
const data = useJSON( | ||
`${baseUri}/api/resource-groups/${resourceGroupId}/queue-metrics.json`, | ||
null | ||
); | ||
if (!data || data.error) return; | ||
|
||
const columns = [ | ||
{ | ||
key: "name", | ||
name: "Resource", | ||
}, | ||
{ | ||
key: "waitTime", | ||
name: "Wait Time", | ||
format: formatTime, | ||
formatHeader: formatHeaderTip( | ||
"Wait time is the average time a job spends waiting in the queue before running on a resource." | ||
), | ||
}, | ||
{ | ||
key: "wallTime", | ||
name: "Wall Time", | ||
format: formatTime, | ||
formatHeader: formatHeaderTip( | ||
"Wall time is the average time a job spends running on a resource." | ||
), | ||
}, | ||
{ | ||
key: "expansionFactor", | ||
name: "Expansion Factor", | ||
format: (value) => value.toFixed(2), | ||
formatHeader: formatHeaderTip( | ||
'Expansion factor is the ratio of the total time (wait time and wall time) to the wall time. It measures how much waiting in the queue "expands" the total time taken to complete a job relative to its length.' | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<> | ||
<h2> | ||
<Icon name="clock" /> | ||
Queue Metrics | ||
</h2> | ||
<Grid columns={columns} rows={data.queueMetrics} /> | ||
</> | ||
); | ||
} |