Skip to content

Commit

Permalink
GUI Launch form, tool form: cluster configuration - set workers insta…
Browse files Browse the repository at this point in the history
…nce type
  • Loading branch information
rodichenko committed Sep 18, 2023
1 parent 2c0e4f4 commit 94dc8c8
Show file tree
Hide file tree
Showing 8 changed files with 559 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ import {
slurmEnabled,
kubeEnabled,
setClusterParameterValue,
getAutoScaledPriceTypeValue
getAutoScaledPriceTypeValue,
applyChildNodeInstanceParameters,
parseChildNodeInstanceConfiguration
} from './utilities/launch-cluster';
import checkModifiedState from './utilities/launch-form-modified-state';
import {
Expand Down Expand Up @@ -280,6 +282,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster: false,
hybridAutoScaledClusterEnabled: false,
gpuScalingConfiguration: undefined,
childNodeInstanceConfiguration: undefined,
gridEngineEnabled: false,
sparkEnabled: false,
slurmEnabled: false,
Expand Down Expand Up @@ -913,6 +916,12 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
},
this.props.preferences
);
const childNodeInstanceConfiguration = parseChildNodeInstanceConfiguration({
autoScaled: autoScaledCluster,
gpuScaling: !!gpuScalingConfiguration,
hybrid: hybridAutoScaledCluster,
parameters: (this.props.parameters || {}).parameters
});
const gridEngineEnabledValue = gridEngineEnabled(this.props.parameters.parameters);
const sparkEnabledValue = sparkEnabled(this.props.parameters.parameters);
const slurmEnabledValue = slurmEnabled(this.props.parameters.parameters);
Expand Down Expand Up @@ -942,6 +951,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster: autoScaledCluster,
hybridAutoScaledClusterEnabled: hybridAutoScaledCluster,
gpuScalingConfiguration,
childNodeInstanceConfiguration,
gridEngineEnabled: gridEngineEnabledValue,
sparkEnabled: sparkEnabledValue,
slurmEnabled: slurmEnabledValue,
Expand Down Expand Up @@ -1000,6 +1010,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster: autoScaledCluster,
hybridAutoScaledClusterEnabled: hybridAutoScaledCluster,
gpuScalingConfiguration,
childNodeInstanceConfiguration,
gridEngineEnabled: gridEngineEnabledValue,
sparkEnabled: sparkEnabledValue,
slurmEnabled: slurmEnabledValue,
Expand Down Expand Up @@ -1190,6 +1201,12 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
this.state.gpuScalingConfiguration,
payload[PARAMETERS]
);
} else if (this.state.childNodeInstanceConfiguration) {
applyChildNodeInstanceParameters(
payload[PARAMETERS],
this.state.childNodeInstanceConfiguration,
this.state.hybridAutoScaledClusterEnabled
);
}
}
if (this.state.launchCluster && this.state.gridEngineEnabled) {
Expand Down Expand Up @@ -1404,6 +1421,12 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
this.state.gpuScalingConfiguration,
payload.params
);
} else if (this.state.childNodeInstanceConfiguration) {
applyChildNodeInstanceParameters(
payload.params,
this.state.childNodeInstanceConfiguration,
this.state.hybridAutoScaledClusterEnabled
);
}
}
if (this.state.launchCluster && this.state.gridEngineEnabled) {
Expand Down Expand Up @@ -1613,6 +1636,12 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
},
this.props.preferences
);
const childNodeInstanceConfiguration = parseChildNodeInstanceConfiguration({
autoScaled: autoScaledCluster,
gpuScaling: !!gpuScalingConfiguration,
hybrid: hybridAutoScaledCluster,
parameters: this.props.parameters.parameters
});
const gridEngineEnabledValue = gridEngineEnabled(this.props.parameters.parameters);
const sparkEnabledValue = sparkEnabled(this.props.parameters.parameters);
const slurmEnabledValue = slurmEnabled(this.props.parameters.parameters);
Expand All @@ -1624,6 +1653,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster: autoScaledCluster,
hybridAutoScaledClusterEnabled: hybridAutoScaledCluster,
gpuScalingConfiguration,
childNodeInstanceConfiguration,
gridEngineEnabled: gridEngineEnabledValue,
sparkEnabled: sparkEnabledValue,
slurmEnabled: slurmEnabledValue,
Expand Down Expand Up @@ -3981,6 +4011,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster,
hybridAutoScaledClusterEnabled,
gpuScalingConfiguration,
childNodeInstanceConfiguration,
nodesCount,
maxNodesCount,
gridEngineEnabled,
Expand All @@ -4002,6 +4033,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster,
hybridAutoScaledClusterEnabled,
gpuScalingConfiguration,
childNodeInstanceConfiguration,
gridEngineEnabled,
sparkEnabled,
slurmEnabled,
Expand Down Expand Up @@ -5642,6 +5674,7 @@ class LaunchPipelineForm extends localization.LocalizedReactComponent {
autoScaledCluster={this.state.autoScaledCluster}
hybridAutoScaledClusterEnabled={this.state.hybridAutoScaledClusterEnabled}
gpuScalingConfiguration={this.state.gpuScalingConfiguration}
childNodeInstanceConfiguration={this.state.childNodeInstanceConfiguration}
gridEngineEnabled={this.state.gridEngineEnabled}
sparkEnabled={this.state.sparkEnabled}
slurmEnabled={this.state.slurmEnabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import React from 'react';
import {Select} from 'antd';
import {getSelectOptions} from '../../../../special/instance-type-info';
import {getInstanceFamily} from '../../../../../utils/instance-family';

function parseCPUConfiguration (configuration) {
const {
Expand Down Expand Up @@ -175,27 +176,106 @@ function getSkippedParameters (preferences, includeOther = true) {
return [...(new Set(parameters))];
}

const emptyValueKey = '__empty__';

const InstanceTypeSelector = (
{
value,
onChange,
instanceTypes = [],
style = {},
gpu = false
gpu = false,
allowEmpty = false,
emptyName,
emptyTooltip
}
) => {
const sorted = instanceTypes.filter(t => !gpu || t.gpu);
const onChangeCallback = (newValue) => {
if (typeof onChange === 'function') {
if (newValue === emptyValueKey) {
onChange(undefined);
} else {
onChange(newValue);
}
}
};
return (
<Select
value={value}
value={value || (allowEmpty ? emptyValueKey : undefined)}
style={style}
onChange={onChange}
onChange={onChangeCallback}
>
{
allowEmpty && (
<Select.Option key={emptyValueKey} value={emptyValueKey} title={emptyTooltip}>
{emptyName || (
<span className="cp-text-not-important">
Not set
</span>
)}
</Select.Option>
)
}
{getSelectOptions(sorted)}
</Select>
);
};

const InstanceFamilySelector = (
{
value,
onChange,
instanceTypes = [],
style = {},
gpu = false,
provider,
allowEmpty = false,
emptyName,
emptyTooltip
}
) => {
const sorted = instanceTypes.filter(t => !gpu || t.gpu);
const families = [...new Set(sorted.map((i) => getInstanceFamily(i, provider)))]
.filter(Boolean)
.sort();
const onChangeCallback = (newValue) => {
if (typeof onChange === 'function') {
if (newValue === emptyValueKey) {
onChange(undefined);
} else {
onChange(newValue);
}
}
};
return (
<Select
value={value || (allowEmpty ? emptyValueKey : undefined)}
style={style}
onChange={onChangeCallback}
>
{
allowEmpty && (
<Select.Option key={emptyValueKey} value={emptyValueKey} title={emptyTooltip}>
{emptyName || (
<span className="cp-text-not-important">
Not set
</span>
)}
</Select.Option>
)
}
{
families.map((family) => (
<Select.Option key={family} value={family}>
{family}
</Select.Option>
))
}
</Select>
);
};

function applyParameters (configuration, parameters) {
if (configuration) {
const {
Expand Down Expand Up @@ -267,5 +347,6 @@ export {
getScalingConfigurationForProvider,
getGPUScalingDefaultConfiguration,
readGPUScalingPreference,
InstanceTypeSelector
InstanceTypeSelector,
InstanceFamilySelector
};
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ const AUTOSCALE_PRICE_TYPE = (
</Row>
</div>
);
const CHILD_NODE_INSTANCE = (
<div>
<Row>
You can specify instance type to be used for autoscaled workers.
</Row>
</div>
);
const CHILD_NODE_INSTANCE_FAMILY = (
<div>
<Row>
You can specify instance family for autoscaled workers and
the exact size will be selected automatically.
</Row>
</div>
);
const GPU_SCALING_TOOLTIP = (
<div>
<Row>
Expand All @@ -143,11 +158,6 @@ const GPU_SCALING_TOOLTIP = (
<Row>
<code>cpu.q</code> for CPU-only tasks and <code>gpu.q</code> for CUDA tasks
</Row>
<Row>If enabled, you can specify instance types to be used for the autoscaled workers.</Row>
<Row>
If selected together with <b>Enable Hybrid cluster</b>
it is possible to specify instance family and the exact size is selected automatically.
</Row>
</div>
);

Expand All @@ -164,6 +174,8 @@ export const LaunchClusterTooltip = {
defaultNodesCount: 'default nodes count',
hybridAutoScaledCluster: 'hybrid',
autoScalePriceType: 'auto scale price type',
childNodeInstance: 'child node instance',
childNodeInstanceFamily: 'child node instance family',
gpuScaling: 'gpu scaling',
enableGridEngine: 'enable grid engine',
enableSlurm: 'enable slurm'
Expand All @@ -188,6 +200,8 @@ const tooltips = {
[LaunchClusterTooltip.autoScaledCluster.hybridAutoScaledCluster]:
HYBRID_AUTOSCALED_CLUSTER_TOOLTIP,
[LaunchClusterTooltip.autoScaledCluster.autoScalePriceType]: AUTOSCALE_PRICE_TYPE,
[LaunchClusterTooltip.autoScaledCluster.childNodeInstance]: CHILD_NODE_INSTANCE,
[LaunchClusterTooltip.autoScaledCluster.childNodeInstanceFamily]: CHILD_NODE_INSTANCE_FAMILY,
[LaunchClusterTooltip.autoScaledCluster.gpuScaling]: GPU_SCALING_TOOLTIP
};

Expand Down
Loading

0 comments on commit 94dc8c8

Please sign in to comment.