-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfixes/fix provider gpus UI #143
Changes from 5 commits
2bc64ef
5dedae5
4565b84
d2dea92
9bd9fd0
38ac4a2
72040a3
a1ea942
c400d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import { Provider } from "@shared/dbSchemas/akash"; | ||
import { Provider, ProviderSnapshotNode } from "@shared/dbSchemas/akash"; | ||
import { Auditor, ProviderAttributesSchema, ProviderList } from "@src/types/provider"; | ||
import semver from "semver"; | ||
|
||
export const mapProviderToList = (provider: Provider, providerAttributeSchema: ProviderAttributesSchema, auditors: Array<Auditor>): ProviderList => { | ||
export const mapProviderToList = ( | ||
provider: Provider, | ||
providerAttributeSchema: ProviderAttributesSchema, | ||
auditors: Array<Auditor>, | ||
nodes?: ProviderSnapshotNode[] | ||
): ProviderList => { | ||
const isValidVersion = provider.cosmosSdkVersion ? semver.gte(provider.cosmosSdkVersion, "v0.45.9") : false; | ||
const name = provider.isOnline ? new URL(provider.hostUri).hostname : null; | ||
const gpuModels = (nodes || []) | ||
.flatMap((x) => x.gpus) | ||
.map((x) => ({ vendor: x.vendor, model: x.name, ram: x.memorySize, interface: x.interface })) | ||
.filter((x, i, arr) => arr.findIndex((o) => x.vendor === o.vendor && x.model === o.model && x.ram === o.ram && x.interface === o.interface) === i); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one is hard to understand, ideally I'd imagine this should be extracted into a named function with some vars that would better explain the conditions. |
||
return { | ||
owner: provider.owner, | ||
|
@@ -42,6 +51,7 @@ export const mapProviderToList = (provider: Provider, providerAttributeSchema: P | |
memory: isValidVersion ? provider.availableMemory : 0, | ||
storage: isValidVersion ? provider.availableStorage : 0 | ||
}, | ||
gpuModels: gpuModels, | ||
uptime1d: provider.uptime1d, | ||
uptime7d: provider.uptime7d, | ||
uptime30d: provider.uptime30d, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,7 +62,7 @@ export const ProviderListRow: React.FunctionComponent<Props> = ({ provider }) => | |||||
const _totalStorage = provider.isOnline | ||||||
? bytesToShrink(provider.availableStats.storage + provider.pendingStats.storage + provider.activeStats.storage) | ||||||
: null; | ||||||
const gpuModels = provider.hardwareGpuModels.map(gpu => gpu.substring(gpu.lastIndexOf(" ") + 1, gpu.length)); | ||||||
const gpuModels = provider.gpuModels.map(x => x.model).filter((x, i, arr) => arr.indexOf(x) === i); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could also utilise that new filter function. What do you think?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I added it to the deploy-web project too. No unit tests for now, but we could add them once the big refactor is done (rebrand). |
||||||
|
||||||
const onStarClick = event => { | ||||||
event.preventDefault(); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,10 +1,8 @@ | ||||||
import { Box, Chip, Paper } from "@mui/material"; | ||||||
import { makeStyles } from "tss-react/mui"; | ||||||
import { useRouter } from "next/router"; | ||||||
import { ClientProviderDetailWithStatus } from "@src/types/provider"; | ||||||
import { LabelValue } from "../shared/LabelValue"; | ||||||
import CheckIcon from "@mui/icons-material/Check"; | ||||||
import { ProviderAttributesSchema } from "@src/types/providerAttributes"; | ||||||
|
||||||
const useStyles = makeStyles()(theme => ({ | ||||||
root: { | ||||||
|
@@ -20,12 +18,16 @@ const useStyles = makeStyles()(theme => ({ | |||||
|
||||||
type Props = { | ||||||
provider: Partial<ClientProviderDetailWithStatus>; | ||||||
providerAttributesSchema: ProviderAttributesSchema; | ||||||
}; | ||||||
|
||||||
export const ProviderSpecs: React.FunctionComponent<Props> = ({ provider, providerAttributesSchema }) => { | ||||||
export const ProviderSpecs: React.FunctionComponent<Props> = ({ provider }) => { | ||||||
const { classes } = useStyles(); | ||||||
const router = useRouter(); | ||||||
|
||||||
const gpuModels = | ||||||
provider?.gpuModels | ||||||
?.map(x => x.model + " " + x.ram) | ||||||
.filter((x, i, arr) => arr.indexOf(x) === i) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.sort((a, b) => a.localeCompare(b)) || []; | ||||||
|
||||||
return ( | ||||||
<Paper className={classes.root}> | ||||||
|
@@ -41,7 +43,7 @@ export const ProviderSpecs: React.FunctionComponent<Props> = ({ provider, provid | |||||
<Box> | ||||||
<LabelValue | ||||||
label="GPU Models" | ||||||
value={provider.hardwareGpuModels.map(x => ( | ||||||
value={gpuModels.map(x => ( | ||||||
<Chip key={x} label={x} size="small" sx={{ marginRight: ".5rem" }} /> | ||||||
))} | ||||||
/> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho this kind of comments don't help much. It's already obvious that
providers
is a providers list. If it's essential to emphasise it's got attributes and auditors (is it?) it can be named accordingly. e.g.providersWithAttrsAndAuditors
. It would also help understanding code better further if it's important.