Skip to content

Commit

Permalink
GUI redundant requests fixes (#3347)
Browse files Browse the repository at this point in the history
* GUI redundant reguests fix: launchForm -settings and -defaultCmd

* GUI redundant reguests fix: launchForm -loadTool

* GUI redundant reguests fix: launchPipeline -settings

* GUI redundant reguests fix: launchPipeline -settings - request status checks
  • Loading branch information
AleksandrGorodetskii authored Aug 29, 2023
1 parent 9184c74 commit 31b1d6d
Showing 1 changed file with 54 additions and 24 deletions.
78 changes: 54 additions & 24 deletions client/src/components/pipelines/launch/LaunchPipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ const DTS_ENVIRONMENT = 'DTS';
runId: params.runId,
configurationName: params.configuration,
image: params.image,
tool: params.image ? new LoadTool(params.image) : undefined,
toolVersion: params.image ? components.version : undefined,
toolSettings: params.image ? new LoadToolVersionSettings(params.image) : undefined,
configurations: params.id && params.version && !isVersionedStorage
? new PipelineConfigurations(params.id, params.version)
: undefined,
Expand All @@ -93,6 +91,10 @@ class LaunchPipeline extends localization.LocalizedReactComponent {

@observable allowedInstanceTypes;
@observable versionedStoragesLaunchPayload;
@observable toolRequest;
@observable toolPending = false;
@observable settingsRequest;
@observable settingsPending = false;

get pipelinePending () {
return !!this.props.pipeline && this.props.pipeline.pending;
Expand All @@ -106,14 +108,6 @@ class LaunchPipeline extends localization.LocalizedReactComponent {
return !!this.props.run && this.props.run.pending;
}

get toolPending () {
return !!this.props.tool && this.props.tool.pending;
}

get toolSettingsPending () {
return !!this.props.toolSettings && this.props.toolSettings.pending;
}

get versionedStoragesLaunchPayloadPending () {
return this.props.isVersionedStorage &&
(
Expand Down Expand Up @@ -207,14 +201,18 @@ class LaunchPipeline extends localization.LocalizedReactComponent {
};

getParameters = () => {
if (this.props.tool &&
if (
this.toolRequest &&
!this.toolPending &&
!this.toolSettingsPending &&
!this.props.tool.error) {
!this.toolRequest.error &&
this.settingsRequest &&
!this.settingsPending &&
!this.settingsRequest.error
) {
const toolVersion = (this.props.toolVersion || 'latest').toLowerCase();
const [versionSettings] = (this.props.toolSettings.value || [])
const [versionSettings] = (this.settingsRequest.value || [])
.filter(v => (v.version || '').toLowerCase() === toolVersion);
const [defaultVersionSettings] = (this.props.toolSettings.value || [])
const [defaultVersionSettings] = (this.settingsRequest.value || [])
.filter(v => (v.version || '').toLowerCase() === 'latest');
const versionSettingValue = (settingName) => {
if (versionSettings &&
Expand All @@ -236,14 +234,14 @@ class LaunchPipeline extends localization.LocalizedReactComponent {
parameter !== undefined &&
`${parameter}`.trim().length > 0 &&
(!additionalCriteria || additionalCriteria(parameter));
const image = `${this.props.tool.value.registry}/${this.props.tool.value.image}`;
const image = `${this.toolRequest.value.registry}/${this.toolRequest.value.image}`;
return {
cmd_template: versionSettingValue('cmd_template') || this.props.tool.value.defaultCommand,
cmd_template: versionSettingValue('cmd_template') || this.toolRequest.value.defaultCommand,
docker_image: this.props.toolVersion
? `${image}:${this.props.toolVersion}`
: image,
instance_disk: +versionSettingValue('instance_disk') || this.props.tool.value.disk,
instance_size: versionSettingValue('instance_size') || this.props.tool.value.instanceType,
instance_disk: +versionSettingValue('instance_disk') || this.toolRequest.value.disk,
instance_size: versionSettingValue('instance_size') || this.toolRequest.value.instanceType,
is_spot: versionSettingValue('is_spot'),
parameters: versionSettingValue('parameters'),
node_count: parameterIsNotEmpty(versionSettingValue('node_count'))
Expand Down Expand Up @@ -505,11 +503,43 @@ class LaunchPipeline extends localization.LocalizedReactComponent {
this.setState({configName: name});
};

loadTool = async (image) => {
if (!image) {
return;
}
this.toolRequest = new LoadTool(image);
this.toolPending = true;
await this.toolRequest.fetch();
if (this.toolRequest.error) {
message.error(this.toolRequest.error, 5);
}
this.toolPending = false;
};

loadSettings = async (image) => {
if (!image) {
return;
}
this.settingsRequest = new LoadToolVersionSettings(image);
this.settingsPending = true;
await this.settingsRequest.fetch();
if (this.settingsRequest.error) {
message.error(this.settingsRequest.error, 5);
}
this.settingsPending = false;
};

componentDidMount () {
this.loadVersionedStorageLaunchPayload();
this.loadTool(this.props.image);
this.loadSettings(this.props.image);
}

componentDidUpdate (prevProps) {
if (this.props.image !== prevProps.image) {
this.loadTool(this.props.image);
this.loadSettings(this.props.image);
}
const parameters = this.getParameters();
if (!this.allowedInstanceTypes) {
this.allowedInstanceTypes = this.props.image
Expand Down Expand Up @@ -585,7 +615,7 @@ class LaunchPipeline extends localization.LocalizedReactComponent {
this.configurationsPending ||
this.runPending ||
this.toolPending ||
this.toolSettingsPending ||
this.settingsPending ||
this.versionedStoragesLaunchPayloadPending ||
(!this.props.preferences.loaded && this.props.preferences.pending) ||
!this.allowedInstanceTypes) {
Expand All @@ -609,15 +639,15 @@ class LaunchPipeline extends localization.LocalizedReactComponent {
type: 'warning'
});
}
if (this.props.tool && this.props.tool.error) {
if (this.toolRequest && this.toolRequest.error) {
alerts.push({
message: this.props.tool.error,
message: this.toolRequest.error,
type: 'warning'
});
}
if (this.props.toolSettings && this.props.toolSettings.error) {
if (this.settingsPending && this.settingsRequest.error) {
alerts.push({
message: this.props.toolSettings.error,
message: this.settingsRequest.error,
type: 'warning'
});
}
Expand Down

0 comments on commit 31b1d6d

Please sign in to comment.