Skip to content

Commit

Permalink
[Frontend] Add support for Memory Based Scheduling with Multiple Inst…
Browse files Browse the repository at this point in the history
…ance Types in ParallelCluster 3.7.0+.
  • Loading branch information
gmarciani committed Oct 13, 2023
1 parent 9244695 commit cb83175
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('given a feature flags provider and a list of rules', () => {
'login_nodes',
'amazon_file_cache',
'job_exclusive_allocation',
'memory_based_scheduling_with_multiple_instance_types',
])
})
})
Expand Down
1 change: 1 addition & 0 deletions frontend/src/feature-flags/featureFlagsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const versionToFeaturesMap: Record<string, AvailableFeature[]> = {
'login_nodes',
'amazon_file_cache',
'job_exclusive_allocation',
'memory_based_scheduling_with_multiple_instance_types',
],
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/feature-flags/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ export type AvailableFeature =
| 'login_nodes'
| 'amazon_file_cache'
| 'job_exclusive_allocation'
| 'memory_based_scheduling_with_multiple_instance_types'
21 changes: 13 additions & 8 deletions frontend/src/old-pages/Configure/Queues/SlurmMemorySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,34 @@ function SlurmMemorySettings() {
const memoryBasedSchedulingEnabled = useState(
memoryBasedSchedulingEnabledPath,
)
const isMemoryBasedSchedulingWithMultipleInstanceTypesActive = useFeatureFlag(
'memory_based_scheduling_with_multiple_instance_types',
)
const queues = useState(queuesPath)
const multipleInstancesTypesSelected = useFeatureFlag(
'queues_multiple_instance_types',
)
? hasMultipleInstanceTypes(queues)
: false

const clearSlurmSettingsState = React.useCallback(() => {
const cannotEnableMemoryBasedScheduling =
multipleInstancesTypesSelected &&
!isMemoryBasedSchedulingWithMultipleInstanceTypesActive
const clearMemoryBasedSettingsState = React.useCallback(() => {
clearState(memoryBasedSchedulingEnabledPath)
if (Object.keys(getState(slurmSettingsPath)).length === 0)
clearState(slurmSettingsPath)
}, [])

React.useEffect(() => {
if (multipleInstancesTypesSelected) {
clearSlurmSettingsState()
if (cannotEnableMemoryBasedScheduling) {
clearMemoryBasedSettingsState()
}
}, [clearSlurmSettingsState, multipleInstancesTypesSelected])
}, [clearMemoryBasedSettingsState, cannotEnableMemoryBasedScheduling])

const toggleMemoryBasedSchedulingEnabled = () => {
!memoryBasedSchedulingEnabled
? setState(memoryBasedSchedulingEnabledPath, true)
: clearSlurmSettingsState()
: clearMemoryBasedSettingsState()
}

const scaledownIdleTime = useState(scaledownIdleTimePath)
Expand Down Expand Up @@ -126,12 +131,12 @@ function SlurmMemorySettings() {
<SpaceBetween size={'s'} direction={'vertical'}>
<Checkbox
checked={memoryBasedSchedulingEnabled}
disabled={multipleInstancesTypesSelected}
disabled={cannotEnableMemoryBasedScheduling}
onChange={toggleMemoryBasedSchedulingEnabled}
>
<Trans i18nKey="wizard.queues.slurmMemorySettings.toggle.label" />
</Checkbox>
{multipleInstancesTypesSelected ? (
{cannotEnableMemoryBasedScheduling ? (
<Alert header={t('wizard.queues.slurmMemorySettings.info.header')}>
{t('wizard.queues.slurmMemorySettings.info.body')}
</Alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import {Queue} from '../queues.types'
import {hasMultipleInstanceTypes} from '../SlurmMemorySettings'

describe('Given a function to validate if mutiple instance types have been selected', () => {
describe('Given a function to validate if multiple instance types have been selected', () => {
describe('if at least a resource of a queue has multiple instance types selected', () => {
const queues: Queue[] = [
{
Expand Down

0 comments on commit cb83175

Please sign in to comment.