Skip to content

Commit

Permalink
fix: merged resource limit affected by resource group remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Sep 6, 2024
1 parent b49b666 commit d990267
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions react/src/hooks/useResourceLimitAndRemaining.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useSuspendedBackendaiClient } from '.';
import { Image } from '../components/ImageEnvironmentSelectFormItems';
import { AUTOMATIC_DEFAULT_SHMEM } from '../components/ResourceAllocationFormItems';
import { addNumberWithUnits, iSizeToSize } from '../helper';
import { useResourceSlots } from '../hooks/backendai';
import { ResourceSlotName, useResourceSlots } from '../hooks/backendai';
import { useSuspenseTanQuery } from './reactQueryAlias';
import _ from 'lodash';
import { useMemo } from 'react';
Expand Down Expand Up @@ -47,9 +47,7 @@ export interface MergedResourceLimits {
}

type ResourceLimits = {
cpu: string | 'Infinity' | 'NaN';
mem: string | 'Infinity' | 'NaN';
'cuda.device': string | 'Infinity' | 'NaN';
[key in ResourceSlotName]?: string | 'Infinity' | 'NaN';
};
type ResourceUsing = ResourceLimits;
type ResourceRemaining = ResourceLimits;
Expand Down Expand Up @@ -237,7 +235,7 @@ export const useResourceLimitAndRemaining = ({
: baiClient._config.maxCPUCoresPerContainer,
limitParser(checkPresetInfo?.keypair_limits.cpu),
limitParser(checkPresetInfo?.group_limits.cpu),
resourceGroupResourceSize?.cpu,
// resourceGroupResourceSize?.cpu,
]),
},
mem:
Expand Down Expand Up @@ -273,8 +271,8 @@ export const useResourceLimitAndRemaining = ({
'g',
)?.number,
// scaling group all mem (using + remaining), string type
resourceGroupResourceSize?.mem &&
iSizeToSize(resourceGroupResourceSize?.mem + '', 'g')?.number,
// resourceGroupResourceSize?.mem &&
// iSizeToSize(resourceGroupResourceSize?.mem + '', 'g')?.number,
]) + 'g',
},
// shmem:
Expand Down Expand Up @@ -306,8 +304,12 @@ export const useResourceLimitAndRemaining = ({
),
max: _.min([
perContainerLimit || 8,
limitParser(
checkPresetInfo?.keypair_limits[key as ResourceSlotName],
),
limitParser(checkPresetInfo?.group_limits[key as ResourceSlotName]),
// scaling group all cpu (using + remaining), string type
resourceGroupResourceSize.accelerators[key],
// resourceGroupResourceSize.accelerators[key],
]),
};
return result;
Expand Down

0 comments on commit d990267

Please sign in to comment.