You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2022/05/06 21:28:15 UTC

[airavata-django-portal] branch develop updated: AIRAVATA-3576 UI setting to control whether to show queue settings for app interface

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2ba4bccc AIRAVATA-3576 UI setting to control whether to show queue settings for app interface
2ba4bccc is described below

commit 2ba4bccc665dbc83ca5b4c15a1a27c072fe37487
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri May 6 17:26:46 2022 -0400

    AIRAVATA-3576 UI setting to control whether to show queue settings for app interface
---
 .../applications/ApplicationInterfaceEditor.vue    | 14 ++++-----
 .../api/migrations/0007_applicationsettings.py     | 21 +++++++++++++
 django_airavata/apps/api/models.py                 |  5 ++++
 django_airavata/apps/api/serializers.py            | 31 ++++++++++++++++++++
 .../js/models/ApplicationInterfaceDefinition.js    |  1 +
 .../ComputationalResourceSchedulingEditor.vue      |  1 +
 .../js/components/experiment/ExperimentSummary.vue | 14 +++++----
 .../components/experiment/QueueSettingsEditor.vue  | 23 +++++++++++++--
 .../js/store/modules/view-experiment.js            | 29 +++++++++++++-----
 .../js/web-components/QueueSettingsEditor.vue      |  3 +-
 .../js/web-components/store.js                     | 34 +++++++++++++++++-----
 11 files changed, 145 insertions(+), 31 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationInterfaceEditor.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationInterfaceEditor.vue
index d41676ab..363aa3cc 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationInterfaceEditor.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationInterfaceEditor.vue
@@ -22,19 +22,19 @@
       </div>
       <div class="col">
         <b-form-group
-          label="Enable Optional File Inputs"
-          label-for="optional-file-inputs"
+          label="Show Queue Settings"
+          label-for="show-queue-settings"
         >
           <b-form-radio-group
-            id="optional-file-inputs"
-            v-model="data.hasOptionalFileInputs"
+            id="show-queue-settings"
+            v-model="data.showQueueSettings"
             :options="trueFalseOptions"
-            :disabled="true"
+            :disabled="readonly"
           >
           </b-form-radio-group>
           <div slot="description">
-            <b>Removed</b>: please add an input of Type URI_COLLECTION with
-            Required set to False instead.
+            Show a queue selector along with queue related settings (nodes,
+            cores, walltime limit).
           </div>
         </b-form-group>
       </div>
diff --git a/django_airavata/apps/api/migrations/0007_applicationsettings.py b/django_airavata/apps/api/migrations/0007_applicationsettings.py
new file mode 100644
index 00000000..1266cbc4
--- /dev/null
+++ b/django_airavata/apps/api/migrations/0007_applicationsettings.py
@@ -0,0 +1,21 @@
+# Generated by Django 3.2.11 on 2022-05-06 18:47
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('django_airavata_api', '0006_applicationtemplate_applicationtemplatecontextprocessor'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='ApplicationSettings',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('application_module_id', models.CharField(max_length=255, unique=True)),
+                ('show_queue_settings', models.BooleanField(default=True)),
+            ],
+        ),
+    ]
diff --git a/django_airavata/apps/api/models.py b/django_airavata/apps/api/models.py
index b6b7e275..24721d04 100644
--- a/django_airavata/apps/api/models.py
+++ b/django_airavata/apps/api/models.py
@@ -59,3 +59,8 @@ class ApplicationTemplateContextProcessor(models.Model):
 
     def __str__(self):
         return self.callable_path
+
+
+class ApplicationSettings(models.Model):
+    application_module_id = models.CharField(max_length=255, unique=True)
+    show_queue_settings = models.BooleanField(default=True)
diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 795e45bb..1006d803 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -337,6 +337,37 @@ class ApplicationInterfaceDescriptionSerializer(
         allow_null=True)
     applicationOutputs = OutputDataObjectTypeSerializer(many=True)
     userHasWriteAccess = serializers.SerializerMethodField()
+    showQueueSettings = serializers.BooleanField(required=False)
+
+    def to_representation(self, instance):
+        representation = super().to_representation(instance)
+        application_module_id = instance.applicationModules[0]
+        application_settings, created = models.ApplicationSettings.objects.get_or_create(
+            application_module_id=application_module_id)
+        representation["showQueueSettings"] = application_settings.show_queue_settings
+        return representation
+
+    def create(self, validated_data):
+        showQueueSettings = validated_data.pop("showQueueSettings", None)
+        application_interface = super().create(validated_data)
+        application_module_id = application_interface.applicationModules[0]
+        if showQueueSettings is not None:
+            models.ApplicationSettings.objects.update_or_create(
+                application_module_id=application_module_id,
+                defaults={"show_queue_settings": showQueueSettings}
+            )
+        return application_interface
+
+    def update(self, instance, validated_data):
+        showQueueSettings = validated_data.pop("showQueueSettings", None)
+        application_interface = super().update(instance, validated_data)
+        application_module_id = application_interface.applicationModules[0]
+        if showQueueSettings is not None:
+            models.ApplicationSettings.objects.update_or_create(
+                application_module_id=application_module_id,
+                defaults={"show_queue_settings": showQueueSettings}
+            )
+        return application_interface
 
     def get_userHasWriteAccess(self, appDeployment):
         request = self.context['request']
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationInterfaceDefinition.js b/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationInterfaceDefinition.js
index 6ed2eeda..010d0ecf 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationInterfaceDefinition.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationInterfaceDefinition.js
@@ -39,6 +39,7 @@ const FIELDS = [
     default: false,
   },
   "userHasWriteAccess",
+  "showQueueSettings",
 ];
 
 export default class ApplicationInterfaceDefinition extends BaseModel {
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ComputationalResourceSchedulingEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ComputationalResourceSchedulingEditor.vue
index 45db176a..1d6245d7 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ComputationalResourceSchedulingEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ComputationalResourceSchedulingEditor.vue
@@ -31,6 +31,7 @@
         <queue-settings-editor
           v-model="data"
           v-if="appDeploymentId"
+          :app-module-id="appModuleId"
           :app-deployment-id="appDeploymentId"
           :compute-resource-policy="selectedComputeResourcePolicy"
           :batch-queue-resource-policies="batchQueueResourcePolicies"
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
index ab10994c..5e8c29ca 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
@@ -173,7 +173,7 @@
                     >
                   </td>
                 </tr>
-                <tr>
+                <tr v-if="showQueueSettings">
                   <th scope="row">Wall Time Limit</th>
                   <td>
                     {{
@@ -183,7 +183,7 @@
                     minutes
                   </td>
                 </tr>
-                <tr>
+                <tr v-if="showQueueSettings">
                   <th scope="row">CPU Count</th>
                   <td>
                     {{
@@ -192,7 +192,7 @@
                     }}
                   </td>
                 </tr>
-                <tr>
+                <tr v-if="showQueueSettings">
                   <th scope="row">Node Count</th>
                   <td>
                     {{
@@ -203,6 +203,7 @@
                 </tr>
                 <tr
                   v-if="
+                    showQueueSettings &&
                     experiment.userConfigurationData
                       .computationalResourceScheduling.totalPhysicalMemory
                   "
@@ -215,7 +216,7 @@
                     MB
                   </td>
                 </tr>
-                <tr>
+                <tr v-if="showQueueSettings">
                   <th scope="row">Queue</th>
                   <td>
                     {{
@@ -313,7 +314,10 @@ export default {
       "launching",
       "clonedExperiment",
     ]),
-    ...mapGetters("viewExperiment", ["finishedOrExecuting"]),
+    ...mapGetters("viewExperiment", [
+      "finishedOrExecuting",
+      "showQueueSettings",
+    ]),
     localFullExperiment() {
       return this.fullExperiment;
     },
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/QueueSettingsEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/QueueSettingsEditor.vue
index 2697b760..da86e071 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/QueueSettingsEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/QueueSettingsEditor.vue
@@ -1,5 +1,5 @@
 <template>
-  <div>
+  <div v-if="showQueueSettings">
     <div class="row">
       <div class="col">
         <div class="card border-default" :class="{ 'border-danger': !valid }">
@@ -203,6 +203,10 @@ export default {
       type: String,
       required: true,
     },
+    appModuleId: {
+      type: String,
+      required: true,
+    },
     computeResourcePolicy: {
       type: models.ComputeResourcePolicy,
       required: false,
@@ -216,7 +220,8 @@ export default {
     return {
       showConfiguration: false,
       appDeploymentQueues: null,
-      enableNodeCountToCpuCheck: true
+      enableNodeCountToCpuCheck: true,
+      applicationInterface: null,
     };
   },
   computed: {
@@ -327,6 +332,11 @@ export default {
     valid() {
       return Object.keys(this.validation).length === 0;
     },
+    showQueueSettings() {
+      return this.applicationInterface
+        ? this.applicationInterface.showQueueSettings
+        : false;
+    },
   },
   methods: {
     queueChanged: function (queueName) {
@@ -458,6 +468,14 @@ export default {
         }
       }
     },
+    loadApplicationInterface() {
+      services.ApplicationModuleService.getApplicationInterface({
+        lookup: this.appModuleId,
+      }).then(
+        (applicationInterface) =>
+          (this.applicationInterface = applicationInterface)
+      );
+    },
   },
   watch: {
     enableNodeCountToCpuCheck() {
@@ -492,6 +510,7 @@ export default {
       }
     });
     this.$on("input", () => this.validate());
+    this.loadApplicationInterface();
   },
 };
 </script>
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/store/modules/view-experiment.js b/django_airavata/apps/workspace/static/django_airavata_workspace/js/store/modules/view-experiment.js
index 46a75a02..c28d2c74 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/store/modules/view-experiment.js
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/store/modules/view-experiment.js
@@ -27,21 +27,27 @@ export const mutations = {
   ) {
     state.runningIntermediateOutputFetches = runningIntermediateOutputFetches;
   },
+  setApplicationInterface(state, { applicationInterface }) {
+    state.applicationInterface = applicationInterface;
+  },
 };
 export const actions = {
-  async setInitialFullExperimentData(
-    { commit, dispatch },
-    { fullExperimentData }
-  ) {
+  async setInitialFullExperimentData({ dispatch }, { fullExperimentData }) {
     const fullExperiment = await services.FullExperimentService.retrieve({
       lookup: fullExperimentData.experimentId,
       initialFullExperimentData: fullExperimentData,
     });
-    commit("setFullExperiment", { fullExperiment });
-    dispatch("initPollingExperiment");
+    dispatch("setFullExperiment", { fullExperiment });
   },
-  setFullExperiment({ dispatch, commit }, { fullExperiment }) {
+  async setFullExperiment({ dispatch, commit }, { fullExperiment }) {
     commit("setFullExperiment", { fullExperiment });
+    const appInterfaceId = fullExperiment.experiment.executionId;
+    const applicationInterface = await services.ApplicationInterfaceService.retrieve(
+      {
+        lookup: appInterfaceId,
+      }
+    );
+    commit("setApplicationInterface", { applicationInterface });
     dispatch("initPollingExperiment");
   },
   setLaunching({ dispatch, commit }, { launching }) {
@@ -218,10 +224,16 @@ export const getters = {
       state.fullExperiment.jobDetails &&
       state.fullExperiment.jobDetails.some(
         (job) =>
-          job.latestJobStatus && job.latestJobStatus.jobState === JobState.ACTIVE
+          job.latestJobStatus &&
+          job.latestJobStatus.jobState === JobState.ACTIVE
       )
     );
   },
+  showQueueSettings(state) {
+    return state.applicationInterface
+      ? state.applicationInterface.showQueueSettings
+      : false;
+  },
 };
 
 const state = {
@@ -230,6 +242,7 @@ const state = {
   polling: false,
   clonedExperiment: null,
   runningIntermediateOutputFetches: {},
+  applicationInterface: null,
 };
 export default {
   namespaced: true,
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/QueueSettingsEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/QueueSettingsEditor.vue
index fc54a12a..d8f8e946 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/QueueSettingsEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/QueueSettingsEditor.vue
@@ -1,5 +1,5 @@
 <template>
-  <div>
+  <div v-if="showQueueSettings">
     <div class="card border-default">
       <b-link
         @click="showConfiguration = !showConfiguration"
@@ -201,6 +201,7 @@ export default {
       getNodeCount: "nodeCount",
       getWallTimeLimit: "wallTimeLimit",
       getTotalPhysicalMemory: "totalPhysicalMemory",
+      showQueueSettings: "showQueueSettings",
     }),
     totalCPUCount() {
       return this.totalCpuCount;
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js
index a774def1..01a181cc 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js
@@ -104,18 +104,22 @@ export const mutations = {
   setAppDeploymentQueues(state, { appDeploymentQueues }) {
     state.appDeploymentQueues = appDeploymentQueues;
   },
+  setApplicationInterface(state, { applicationInterface }) {
+    state.applicationInterface = applicationInterface;
+  },
 };
 export const actions = {
   async loadNewExperiment({ commit, dispatch }, { applicationId }) {
     const applicationModule = await services.ApplicationModuleService.retrieve({
       lookup: applicationId,
     });
-    const appInterface = await services.ApplicationModuleService.getApplicationInterface(
+    const applicationInterface = await services.ApplicationModuleService.getApplicationInterface(
       {
         lookup: applicationId,
       }
     );
-    const experiment = appInterface.createExperiment();
+    commit("setApplicationInterface", { applicationInterface });
+    const experiment = applicationInterface.createExperiment();
     const currentDate = new Date().toLocaleString([], {
       dateStyle: "medium",
       timeStyle: "short",
@@ -128,11 +132,14 @@ export const actions = {
     const experiment = await services.ExperimentService.retrieve({
       lookup: experimentId,
     });
-    const appInterface = await services.ApplicationInterfaceService.retrieve({
-      lookup: experiment.executionId,
-    });
+    const applicationInterface = await services.ApplicationInterfaceService.retrieve(
+      {
+        lookup: experiment.executionId,
+      }
+    );
+    commit("setApplicationInterface", { applicationInterface });
     commit("setApplicationModuleId", {
-      applicationModuleId: appInterface.applicationModuleId,
+      applicationModuleId: applicationInterface.applicationModuleId,
     });
     await dispatch("setExperiment", { experiment });
   },
@@ -286,7 +293,10 @@ export const actions = {
     }
     dispatch("initializeQueue");
   },
-  updateTotalCPUCount({ commit, getters, state }, { totalCPUCount, enableNodeCountToCpuCheck }) {
+  updateTotalCPUCount(
+    { commit, getters, state },
+    { totalCPUCount, enableNodeCountToCpuCheck }
+  ) {
     if (state.experiment) {
       commit("updateExperimentTotalCPUCount", { totalCPUCount });
     } else {
@@ -305,7 +315,10 @@ export const actions = {
       }
     }
   },
-  updateNodeCount({ commit, getters, state }, { nodeCount, enableNodeCountToCpuCheck }) {
+  updateNodeCount(
+    { commit, getters, state },
+    { nodeCount, enableNodeCountToCpuCheck }
+  ) {
     if (state.experiment) {
       commit("updateExperimentNodeCount", { nodeCount });
     } else {
@@ -804,6 +817,10 @@ export const getters = {
   maxMemory: (state, getters) => {
     return getters.queue ? getters.queue.maxMemory : 0;
   },
+  showQueueSettings: (state) =>
+    state.applicationInterface
+      ? state.applicationInterface.showQueueSettings
+      : false,
 };
 
 export default new Vuex.Store({
@@ -826,6 +843,7 @@ export default new Vuex.Store({
     totalPhysicalMemory: null,
     groupResourceProfileId: null,
     resourceHostId: null,
+    applicationInterface: null,
   },
   mutations,
   actions,