-
Notifications
You must be signed in to change notification settings - Fork 56
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2bc64ef
Return gpus in provider endpoints
Redm4x 5dedae5
Display gpus from feature discovery instead of capabilities
Redm4x 4565b84
Add missing indexes
Redm4x d2dea92
Change to inner join
Redm4x 9bd9fd0
.
Redm4x 38ac4a2
Code improvements
Redm4x 72040a3
.
Redm4x a1ea942
Add array helper
Redm4x c400d69
Add createFilterUnique to deploy-web project
Redm4x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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,19 @@ | ||
import { createFilterUnique } from "./array"; | ||
|
||
describe("array helpers", () => { | ||
describe("createFilterUnique", () => { | ||
it("should return a functionning unique filter with default equality matcher", () => { | ||
const arrayWithDuplicate = [1, 2, 2, 3, 3, 3]; | ||
const expected = [1, 2, 3]; | ||
|
||
expect(arrayWithDuplicate.filter(createFilterUnique())).toEqual(expected); | ||
}); | ||
|
||
it("should return a functionning unique filter with custom matcher", () => { | ||
const arrayWithDuplicate = [{ v: 1 }, { v: 2 }, { v: 2 }, { v: 3 }, { v: 3 }, { v: 3 }]; | ||
const expected = [{ v: 1 }, { v: 2 }, { v: 3 }]; | ||
|
||
expect(arrayWithDuplicate.filter(createFilterUnique((a, b) => a.v === b.v))).toEqual(expected); | ||
}); | ||
}); | ||
}); |
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,7 @@ | ||
type Matcher<T> = (a: T, b: T) => boolean; | ||
|
||
export function createFilterUnique<T>(matcher: Matcher<T> = (a, b) => a === b): (value: T, index: number, array: T[]) => boolean { | ||
return (value, index, array) => { | ||
return array.findIndex((other) => matcher(value, other)) === index; | ||
}; | ||
} |
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 | ||||
---|---|---|---|---|---|---|
@@ -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" }} /> | ||||||
))} | ||||||
/> | ||||||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This could also utilise that new filter function. What do you think?
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.
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).