Skip to content

Commit

Permalink
DemandedHardwarePerformance['demandTierName'] utilized in Demand Moni…
Browse files Browse the repository at this point in the history
…tor Table (#1251)
  • Loading branch information
vitto-moz authored Dec 19, 2024
1 parent 90b988f commit d2417e3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { SaladTheme } from '../../../../SaladTheme'
import type { DemandedHardwarePerformance } from '../../DemandMonitorStore'
import { demandMonitorTableColumns, demandPillColors } from './constants'
import type { DemandMonitorTableColumn, DemandMonitorTableSort } from './types'
import { getHardwareDemandLevel, sortHardwareDemandPerformance } from './utils'
import { sortHardwareDemandPerformance } from './utils'

const styles: (theme: SaladTheme) => Record<string, CSS.Properties> = (theme: SaladTheme) => ({
tableWrapper: {
Expand Down Expand Up @@ -190,9 +190,7 @@ const _DemandMonitorTable: FunctionComponent<Props> = ({ classes, demandedHardwa
</thead>
<tbody>
{sortedDemandedHardwarePerformanceList.map(
({ displayName, earningRates, recommendedSpecs, utilizationPct }) => {
const demand = getHardwareDemandLevel(utilizationPct)

({ displayName, earningRates, recommendedSpecs, demandTierName }) => {
return (
<tr key={displayName}>
<td className={classNames(classes.gpuWrapper, classes.tableCell, classes.greenTableCell)}>
Expand All @@ -215,11 +213,11 @@ const _DemandMonitorTable: FunctionComponent<Props> = ({ classes, demandedHardwa
<div
className={classes.demandPill}
style={{
backgroundColor: demandPillColors[demand].background,
color: demandPillColors[demand].text,
backgroundColor: demandPillColors[demandTierName].background,
color: demandPillColors[demandTierName].text,
}}
>
<Text variant="baseXS">{demand}</Text>
<Text variant="baseXS">{demandTierName}</Text>
</div>
</td>
<td className={classes.tableCell}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Demand, DemandMonitorTableColumn } from './types'
import type { DemandedHardwarePerformance } from '../../DemandMonitorStore'
import type { DemandMonitorTableColumn } from './types'
import {
sortByAvgEarningRate,
sortByDemand,
Expand All @@ -12,7 +13,7 @@ interface DemandPillColors {
background: string
}

export const demandPillColors: Record<Demand, DemandPillColors> = {
export const demandPillColors: Record<DemandedHardwarePerformance['demandTierName'], DemandPillColors> = {
Low: {
text: 'white',
background: '#546470',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import type { DemandedHardwarePerformance } from '../../DemandMonitorStore'

export type Demand = 'Low' | 'Moderate' | 'High'

export interface DemandMonitorItem {
gpu: string
hourlyRate: string
recommendedSpecs: { ram: string; storage: string }
demand: Demand
demand: DemandedHardwarePerformance['demandTierName']
avgEarnings: string
avgRunningTime: string
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import type { DemandedHardwarePerformance } from '../../DemandMonitorStore'
import type { Demand, DemandMonitorTableSort, DemandMonitorTableSortRule } from './types'

export const getHardwareDemandLevel = (utilizationPercentage: number): Demand => {
if (utilizationPercentage > 80) {
return 'High'
}
if (utilizationPercentage < 50) {
return 'Low'
}

return 'Moderate'
}
import type { DemandMonitorTableSort, DemandMonitorTableSortRule } from './types'

interface SortHardwareDemandPerformanceParams {
demandedHardwarePerformanceList: DemandedHardwarePerformance[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { demandMonitorGpuEndpointPath } from './constants'
export interface DemandedHardwarePerformance {
name: string
displayName: string
demandTier: 'low' | 'mid' | 'high'
demandTierName: 'Low' | 'Moderate' | 'High'
earningRates: {
avgEarningRate: number
top25PctEarningRate: number
Expand Down

0 comments on commit d2417e3

Please sign in to comment.