Skip to content
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

feat: support cuda.mem type #2486

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions react/src/components/AgentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import BAIProgressWithLabel from './BAIProgressWithLabel';
import BAIPropertyFilter from './BAIPropertyFilter';
import DoubleTag from './DoubleTag';
import Flex from './Flex';
import { ResourceTypeIcon, ResourceTypeKey } from './ResourceNumber';
import { ResourceTypeIcon } from './ResourceNumber';
import TableColumnsSettingModal from './TableColumnsSettingModal';
import { AgentDetailModalFragment$key } from './__generated__/AgentDetailModalFragment.graphql';
import {
Expand Down Expand Up @@ -361,10 +361,7 @@ const AgentList: React.FC<AgentListProps> = ({
return (
<Flex key={key} justify="between" style={{ minWidth: 220 }}>
<Flex gap="xxs">
<ResourceTypeIcon
key={key as ResourceTypeKey}
type={key as ResourceTypeKey}
/>
<ResourceTypeIcon key={key} type={key} />
<Typography.Text>
{parsedOccupiedSlots[key] ?? 0}/
{parsedAvailableSlots[key] ?? 0}
Expand Down
7 changes: 6 additions & 1 deletion react/src/components/DynamicUnitInputNumberWithSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ const DynamicUnitInputNumberWithSlider: React.FC<
...otherProps
}) => {
const [value, setValue] = useControllableValue<string | undefined | null>(
otherProps,
{
...otherProps,
value: _.isNumber(otherProps.value)
? String(otherProps.value) + units[0]
: otherProps.value,
},
{
defaultValue: '0g',
},
Expand Down
7 changes: 5 additions & 2 deletions react/src/components/InputNumberWithSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { useEffect } from 'react';

type OmitControlledProps<T> = Omit<T, 'value' | 'onChange'>;

interface InputNumberWithSliderProps {
export interface InputNumberWithSliderProps {
min?: number;
max?: number;
step?: number | null;
Expand All @@ -29,7 +29,10 @@ const InputNumberWithSlider: React.FC<InputNumberWithSliderProps> = ({
sliderProps,
...otherProps
}) => {
const [value, setValue] = useControllableValue(otherProps);
const [value, setValue] = useControllableValue({
...otherProps,
value: _.isNumber(otherProps.value) ? otherProps.value : min,
});
const inputRef = React.useRef<HTMLInputElement>(null);
useEffect(() => {
// when step is 1, make sure the value is integer
Expand Down
53 changes: 53 additions & 0 deletions react/src/components/MultipleTypeInputWithSlider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// This is a draft version.
// It doesn't seem to be a good idea to compare using two inputs with different units by composition on parent.
import DynamicUnitInputNumberWithSlider from './DynamicUnitInputNumberWithSlider';
import InputNumberWithSlider, {
InputNumberWithSliderProps,
} from './InputNumberWithSlider';
import { useControllableValue } from 'ahooks';
import React from 'react';

interface MultipleTypeInputWithSliderProps
extends Omit<InputNumberWithSliderProps, 'min' | 'max' | 'step'> {
type: 'number' | 'bytes';
min?: number;
max?: number;
}

const MultipleTypeInputWithSlider: React.FC<
MultipleTypeInputWithSliderProps
> = ({
type,
inputNumberProps,
sliderProps,
min,
max,
value: _valueFromProps,
onChange: _onChangeFromProps,
...props
}) => {
const [value, setValue] = useControllableValue({
value: _valueFromProps,
onChange: _onChangeFromProps,
});
return type === 'bytes' ? (
<DynamicUnitInputNumberWithSlider
{...props}
value={value}
onChange={setValue}
extraMarks={sliderProps?.marks}
/>
) : (
<InputNumberWithSlider
{...props}
min={min}
max={max}
inputNumberProps={inputNumberProps}
sliderProps={sliderProps}
value={value}
onChange={setValue}
/>
);
};

export default MultipleTypeInputWithSlider;
Loading
Loading