-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: typo lease details (oseq -> dseq) * fix: exception when manifest request fails * feat: gpu support * feat: add gpu support in sdl editor * chore: update akashjs version
- Loading branch information
Showing
19 changed files
with
4,557 additions
and
4,515 deletions.
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,49 @@ | ||
import React from 'react'; | ||
import { Button, Stack, Link, Tooltip, ButtonProps } from '@mui/material'; | ||
|
||
type DeploymentActionButtonProps = { | ||
tooltipTitle: string; | ||
tooltip: React.ReactNode; | ||
linkTo: string; | ||
children: React.ReactNode; | ||
} & ButtonProps; | ||
|
||
const ConditionalTooltip = ({ children, condition, ...rest}: any) => { | ||
return condition | ||
? <Link {...rest}>{children}</Link> | ||
: <Tooltip {...rest} placement="top">{children}</Tooltip>; | ||
}; | ||
|
||
|
||
const DeploymentActionButton: React.FC<DeploymentActionButtonProps> = (props) => { | ||
const { | ||
tooltipTitle, | ||
tooltip, | ||
linkTo, | ||
children, | ||
...rest | ||
} = props; | ||
|
||
return <Stack direction="row" spacing={1} marginBottom="0.75rem" alignItems="center"> | ||
<ConditionalTooltip | ||
title={tooltipTitle} | ||
to={linkTo} | ||
className="grow" | ||
> | ||
<Button | ||
fullWidth | ||
variant="outlined" | ||
color="secondary" | ||
sx={{ | ||
justifyContent: 'left' | ||
}} | ||
{...rest} | ||
> | ||
{children} | ||
</Button> | ||
</ConditionalTooltip> | ||
{tooltip} | ||
</Stack>; | ||
}; | ||
|
||
export default DeploymentActionButton; |
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,156 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { Field, useFormikContext } from 'formik'; | ||
import { MeasurementControl } from '../MeasurementControl'; | ||
import { AddNewButton, AddNewButtonWrapper, FieldWrapper, PlusSign, SdlSectionWrapper } from './styling'; | ||
import { Button, Box, Stack, Typography, List, ListItem, OutlinedInput } from '@mui/material'; | ||
import { IconTrash } from '../Icons'; | ||
|
||
type GpuUnitProps = { | ||
currentProfile: string; | ||
disabled: boolean; | ||
}; | ||
|
||
type GpuProps = { | ||
currentProfile: string; | ||
disabled: boolean; | ||
}; | ||
|
||
const GpuUnits: React.FC<GpuUnitProps> = ({ currentProfile, disabled }) => { | ||
const { setFieldValue, values } = useFormikContext<any>(); | ||
|
||
const handleSetUnits = useCallback((name: string, units: string) => { | ||
const unitsAsInt = parseInt(units); | ||
setFieldValue(`sdl.profiles.compute.${currentProfile}.resources.gpu.units`, unitsAsInt); | ||
}, [currentProfile, setFieldValue]); | ||
|
||
return ( | ||
<FieldWrapper> | ||
<Field | ||
name={`sdl.profiles.compute.${currentProfile}.resources.gpu.units`} | ||
defaultValue={formValues.sdl.profiles.compute[currentProfile].resources.gpu.units || 0} | ||
id="gpu" | ||
> | ||
{({ field, form, meta }: any) => ( | ||
<React.Fragment> | ||
<MeasurementControl | ||
error={meta?.error} | ||
title="GPU" | ||
subTitle="GPUs Required" | ||
setFieldValue={handleSetUnits} | ||
type="number" | ||
withOutSuffix | ||
disabled={disabled} | ||
{...field} | ||
> | ||
</MeasurementControl> | ||
</React.Fragment> | ||
)} | ||
</Field> | ||
</FieldWrapper> | ||
); | ||
}; | ||
|
||
// tag based component for selecting which gpus to allow. | ||
const GpuAttributes: React.FC<GpuUnitProps> = ({ currentProfile, disabled }) => { | ||
const { setFieldValue, values } = useFormikContext(); | ||
const formValues = (values as any); | ||
|
||
const [attributes, setAttributes] = useState<string[]>(() => { | ||
const attributes = formValues.sdl.profiles.compute[currentProfile].resources.gpu.attributes; | ||
if (attributes) { | ||
return attributes.map((attr: any) => attr.key); | ||
} | ||
return []; | ||
}); | ||
|
||
const handleSetAttributes = useCallback((attributes: string[]) => { | ||
const attrObjs = attributes | ||
.filter((attr) => attr !== '') | ||
.map((key) => ({ key, value: true })); | ||
|
||
setFieldValue(`sdl.profiles.compute.${currentProfile}.resources.gpu.attributes`, attrObjs); | ||
}, [currentProfile, setFieldValue]); | ||
|
||
const addAttribute = useCallback(() => { | ||
setAttributes((attributes) => [...attributes, '']); | ||
}, []); | ||
|
||
const removeAttribute = useCallback((index: number) => { | ||
setAttributes((attributes) => attributes.filter((_, i) => i !== index)); | ||
}, []); | ||
|
||
return ( | ||
<FieldWrapper> | ||
<Typography variant="body2" color="text.secondary" marginTop={2}> | ||
Example filters: | ||
<List> | ||
<ListItem>/vendor/nvidia/model/a6000 (nVidia A6000 only)</ListItem> | ||
<ListItem>/vendor/amd/model/* (any AMD GPU)</ListItem> | ||
</List> | ||
</Typography> | ||
<Stack gap={1}> | ||
{attributes.map((attribute, index) => ( | ||
<Stack direction="row" key={index} gap={1}> | ||
<Box | ||
flexGrow={1} | ||
> | ||
<OutlinedInput | ||
type="text" | ||
placeholder="Enter GPU Filter" | ||
value={attribute} | ||
fullWidth={true} | ||
inputProps={{ | ||
style: { | ||
padding: '10px 16px', | ||
} | ||
}} | ||
onChange={(e) => { | ||
const newAttributes = [...attributes]; | ||
newAttributes[index] = e.target.value; | ||
setAttributes(newAttributes); | ||
handleSetAttributes(newAttributes); | ||
}} | ||
/> | ||
</Box> | ||
<Button onClick={() => removeAttribute(index)} | ||
aria-label='delete' | ||
variant="outlined"> | ||
<IconTrash /> | ||
</Button> | ||
</Stack> | ||
))} | ||
|
||
{!disabled && ( | ||
<AddNewButtonWrapper> | ||
<AddNewButton | ||
startIcon={<PlusSign />} | ||
variant="outlined" | ||
size="small" | ||
onClick={addAttribute} | ||
> | ||
Add New GPU Filter | ||
</AddNewButton> | ||
</AddNewButtonWrapper> | ||
)} | ||
</Stack> | ||
</FieldWrapper > | ||
); | ||
}; | ||
|
||
export const Gpu: React.FC<GpuProps> = ({ currentProfile, disabled }) => { | ||
const { values } = useFormikContext<any>(); | ||
|
||
return ( | ||
<SdlSectionWrapper> | ||
<Typography variant="h4"> | ||
GPUs | ||
</Typography> | ||
<Stack> | ||
<GpuUnits currentProfile={currentProfile} disabled={disabled} /> | ||
{values.sdl.profiles.compute[currentProfile].resources.gpu.units > 0 && ( | ||
<GpuAttributes currentProfile={currentProfile} disabled={disabled} /> | ||
)} | ||
</Stack> | ||
</SdlSectionWrapper> | ||
); | ||
}; |
Oops, something went wrong.