Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.
Merged
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
6 changes: 6 additions & 0 deletions frontend/locales/en/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"queues": {
"validation": {
"instanceTypeUnique": "Instance types must be unique within a Queue.",
"instanceTypeMissing": "Select at least once instance type.",
"selectSubnet": "You must select a Subnet.",
"setRootVolumeSize": "You must set a RootVolume size.",
"rootVolumeMinimum": "You must use an integer >= 35GB for Root Volume Size.",
Expand All @@ -300,6 +301,11 @@
"dismissAriaLabel": "Close alert"
}
},
"allocationStrategy": {
"title": "Allocation strategy",
"lowestPrice": "Lowest price",
"capacityOptimized": "Capacity optimized"
},
"schedulableMemory": {
"name": "Schedulable Memory (MiB)",
"description": "Amount of memory in MiB to be made available to jobs on the compute nodes of the compute resource",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('given a feature flags provider and a list of rules', () => {
'memory_based_scheduling',
'slurm_queue_update_strategy',
'slurm_accounting',
'queues_multiple_instance_types',
])
})
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/feature-flags/featureFlagsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const versionToFeaturesMap: Record<string, AvailableFeature[]> = {
'multiuser_cluster',
'slurm_queue_update_strategy',
],
'3.3.0': ['slurm_accounting'],
'3.3.0': ['slurm_accounting', 'queues_multiple_instance_types'],
}

function composeFlagsListByVersion(currentVersion: string): AvailableFeature[] {
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 @@ -16,3 +16,4 @@ export type AvailableFeature =
| 'memory_based_scheduling'
| 'slurm_accounting'
| 'slurm_queue_update_strategy'
| 'queues_multiple_instance_types'
7 changes: 7 additions & 0 deletions frontend/src/feature-flags/useFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import {AvailableFeature} from './types'

export function useFeatureFlag(feature: AvailableFeature): boolean {
const version = useState(['app', 'version', 'full'])
return isFeatureEnabled(version, feature)
}

export function isFeatureEnabled(
version: string,
feature: AvailableFeature,
): boolean {
const features = new Set(featureFlagsProvider(version))

return features.has(feature)
Expand Down
18 changes: 12 additions & 6 deletions frontend/src/old-pages/Configure/Cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import {LoadAwsConfig} from '../../model'
// Components
import {LabeledIcon, CustomAMISettings} from './Components'
import {useFeatureFlag} from '../../feature-flags/useFeatureFlag'
import {useComputeResourceAdapter} from './Queues/Queues'
import {createComputeResource as singleCreate} from './Queues/SingleInstanceComputeResource'
import {createComputeResource as multiCreate} from './Queues/MultiInstanceComputeResource'

// Constants
const errorsPath = ['app', 'wizard', 'errors', 'cluster']
Expand Down Expand Up @@ -342,6 +345,9 @@ function Cluster() {
let defaultRegion = useState(['aws', 'region']) || ''
const region = useState(['app', 'selectedRegion']) || defaultRegion
const isMultiuserClusterActive = useFeatureFlag('multiuser_cluster')
const isMultipleInstanceTypesActive = useFeatureFlag(
'queues_multiple_instance_types',
)

React.useEffect(() => {
const configPath = ['app', 'wizard', 'config']
Expand All @@ -366,13 +372,13 @@ function Cluster() {
[
{
Name: 'queue0',
AllocationStrategy: isMultipleInstanceTypesActive
? 'lowest-price'
: undefined,
ComputeResources: [
{
Name: 'queue0-t2-micro',
MinCount: 0,
MaxCount: 4,
InstanceType: 't2.micro',
},
isMultipleInstanceTypesActive
? multiCreate(0, 0)
: singleCreate(0, 0),
],
},
],
Expand Down
25 changes: 10 additions & 15 deletions frontend/src/old-pages/Configure/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,12 @@ function SubnetSelect({value, onChange, disabled}: any) {
)
}

function InstanceSelect({path, selectId, callback, disabled}: any) {
const value = useState(path) || ''
// instance type, description, image
type InstanceGroup = [string, string, string][]

export function useInstanceGroups(): Record<string, InstanceGroup> {
const instanceTypes = useState(['aws', 'instanceTypes']) || []

let groupNames = [
'General Purpose',
'Compute',
'HPC',
'High Memory',
'Graviton',
'Mixed',
'GPU',
]

let groups: {[key: string]: [string, string, string][]} = {}

for (let instance of instanceTypes) {
Expand Down Expand Up @@ -227,8 +218,12 @@ function InstanceSelect({path, selectId, callback, disabled}: any) {

groups[group].push([instance.InstanceType, desc, img])
}
return groups
}

groupNames = groupNames.filter(name => name in groups)
function InstanceSelect({path, selectId, callback, disabled}: any) {
const value = useState(path) || ''
const instanceGroups = useInstanceGroups()

// @ts-expect-error TS(7031) FIXME: Binding element 'value' implicitly has an 'any' ty... Remove this comment to see the full error message
const instanceToOption = ([value, label, icon]) => {
Expand All @@ -255,10 +250,10 @@ function InstanceSelect({path, selectId, callback, disabled}: any) {
ariaLabel="Instance Selector"
placeholder="Instance Type"
empty="No matches found"
options={groupNames.map(groupName => {
options={Object.keys(instanceGroups).map(groupName => {
return {
label: groupName,
options: groups[groupName].map(instanceToOption),
options: instanceGroups[groupName].map(instanceToOption),
}
})}
/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/old-pages/Configure/Configure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {Cluster, clusterValidate} from './Cluster'
import {HeadNode, headNodeValidate} from './HeadNode'
import {MultiUser, multiUserValidate} from './MultiUser'
import {Storage, storageValidate} from './Storage'
import {Queues, queuesValidate} from './Queues'
import {Queues, queuesValidate} from './Queues/Queues'
import {
Create,
createValidate,
Expand Down
Loading