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 2018/01/04 19:35:58 UTC

[airavata-django-portal] branch master updated: AIRAVATA-2598 Factor out ComputationalResourceSchedulingEditor

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0a61a3e  AIRAVATA-2598 Factor out ComputationalResourceSchedulingEditor
0a61a3e is described below

commit 0a61a3e9c2b6587a6351f8093627e56cf01b45a1
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Jan 4 14:34:42 2018 -0500

    AIRAVATA-2598 Factor out ComputationalResourceSchedulingEditor
---
 .../ComputationalResourceSchedulingEditor.vue      | 113 +++++++++++++++++++++
 .../js/components/experiment/ExperimentEditor.vue  |  66 ++----------
 .../components/experiment/QueueSettingsEditor.vue  |  12 +--
 3 files changed, 121 insertions(+), 70 deletions(-)

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
new file mode 100644
index 0000000..08af0ea
--- /dev/null
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ComputationalResourceSchedulingEditor.vue
@@ -0,0 +1,113 @@
+<template>
+    <b-form novalidate>
+        <b-form-group label="Compute Resource" label-for="compute-resource">
+            <b-form-select id="compute-resource"
+                v-model="resourceHostId"
+                :options="computeResourceOptions" required
+                @change="computeResourceChanged">
+                <template slot="first">
+                    <option :value="null" disabled>Select a Compute Resource</option>
+                </template>
+            </b-form-select>
+        </b-form-group>
+
+        <queue-settings-editor
+            v-model="localComputationalResourceScheduling"
+            v-if="appDeploymentId"
+            :app-deployment-id="appDeploymentId"
+            @input="queueSettingsChanged">
+        </queue-settings-editor>
+    </b-form>
+</template>
+
+<script>
+import QueueSettingsEditor from './QueueSettingsEditor.vue'
+import {models, services} from 'django-airavata-api'
+
+export default {
+    name: 'computational-resource-scheduling-editor',
+    props: {
+        value: {
+            type: models.ComputationalResourceSchedulingModel,
+            required: true
+        },
+        appModuleId: {
+            type: String,
+            required: true
+        },
+        appInterfaceId: {
+            type: String,
+            required: true
+        },
+    },
+    data () {
+        return {
+            localComputationalResourceScheduling: this.value.clone(),
+            computeResources: {},
+            applicationDeployments: [],
+            appDeploymentId: null,
+            resourceHostId: null,
+        }
+    },
+    components: {
+        QueueSettingsEditor,
+    },
+    mounted: function () {
+        this.loadApplicationDeployments(this.appModuleId);
+        this.loadComputeResourcesForApplicationInterface(this.appInterfaceId);
+    },
+    computed: {
+        computeResourceOptions: function() {
+            const computeResourceOptions = [];
+            for (let computeResourceId in this.computeResources) {
+                if (this.computeResources.hasOwnProperty(computeResourceId)) {
+                    computeResourceOptions.push({
+                        value: computeResourceId,
+                        text: this.computeResources[computeResourceId],
+                    })
+                }
+            }
+            computeResourceOptions.sort((a, b) => a.text.localeCompare(b.text));
+            return computeResourceOptions;
+        },
+    },
+    methods: {
+        computeResourceChanged: function(selectedComputeResourceId) {
+            this.localComputationalResourceScheduling.resourceHostId = selectedComputeResourceId;
+            this.emitValueChanged();
+            // Find application deployment that corresponds to this compute resource
+            let selectedApplicationDeployment = this.applicationDeployments.find(dep => dep.computeHostId === selectedComputeResourceId);
+            if (!selectedApplicationDeployment) {
+                throw new Error("Failed to find application deployment!");
+            }
+            this.appDeploymentId = selectedApplicationDeployment.appDeploymentId;
+        },
+        loadApplicationDeployments: function(appModuleId) {
+            services.ApplicationModuleService.getApplicationDeployments(appModuleId)
+                .then(applicationDeployments => {
+                    this.applicationDeployments = applicationDeployments;
+                });
+        },
+        loadComputeResourcesForApplicationInterface: function(appInterfaceId) {
+            services.ApplicationInterfaceService.getComputeResources(appInterfaceId)
+                .then(computeResources => this.computeResources = computeResources);
+        },
+        queueSettingsChanged: function() {
+            // QueueSettingsEditor updates the full
+            // ComputationalResourceSchedulingModel instance but doesn't know
+            // the resourceHostId so we need to copy it back into the instance
+            // whenever it changes
+            this.localComputationalResourceScheduling.resourceHostId = this.resourceHostId;
+            this.emitValueChanged();
+        },
+        emitValueChanged: function() {
+            this.$emit('input', this.localComputationalResourceScheduling);
+        }
+    },
+    watch: {
+    }
+}
+</script>
+
+<style>
+</style>
\ No newline at end of file
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue
index 1e9db4e..2852745 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue
@@ -55,28 +55,11 @@
                         <h2 class="h5 mb-3">
                             Resource Selection
                         </h2>
-                        <b-form novalidate>
-                            <!-- TODO: combine compute resource selector with
-                            queue-settings-editor to create a
-                            ComputationalResourceSchedulingModelEditor component -->
-                            <b-form-group label="Compute Resource" label-for="compute-resource">
-                                <b-form-select id="compute-resource"
-                                    v-model="resourceHostId"
-                                    :options="computeResourceOptions" required
-                                    @change="computeResourceChanged">
-                                    <template slot="first">
-                                        <option :value="null" disabled>Select a Compute Resource</option>
-                                    </template>
-                                </b-form-select>
-                            </b-form-group>
-
-                            <queue-settings-editor
-                                v-model="experiment.userConfigurationData.computationalResourceScheduling"
-                                v-if="appDeploymentId && resourceHostId"
-                                :app-deployment-id="appDeploymentId"
-                                :resource-host-id="resourceHostId">
-                            </queue-settings-editor>
-                        </b-form>
+                        <computational-resource-scheduling-editor
+                            v-model="experiment.userConfigurationData.computationalResourceScheduling"
+                            :app-module-id="appModule.appModuleId"
+                            :app-interface-id="appInterface.applicationInterfaceId">
+                        </computational-resource-scheduling-editor>
                     </div>
                 </div>
             </div>
@@ -85,6 +68,7 @@
 </template>
 
 <script>
+import ComputationalResourceSchedulingEditor from './ComputationalResourceSchedulingEditor.vue'
 import QueueSettingsEditor from './QueueSettingsEditor.vue'
 import {models, services} from 'django-airavata-api'
 
@@ -95,24 +79,15 @@ export default {
     data () {
         return {
             projects: [],
-            computeResources: {},
-            applicationDeployments: [],
-            appDeploymentId: null,
-            resourceHostId: null,
         }
     },
     components: {
         QueueSettingsEditor,
+        ComputationalResourceSchedulingEditor,
     },
     mounted: function () {
         services.ProjectService.listAll()
             .then(projects => this.projects = projects);
-        services.ApplicationModuleService.getApplicationDeployments(this.appModule.appModuleId)
-            .then(applicationDeployments => {
-                this.applicationDeployments = applicationDeployments;
-            });
-        services.ApplicationInterfaceService.getComputeResources(this.appInterface.applicationInterfaceId)
-            .then(computeResources => this.computeResources = computeResources);
     },
     computed: {
         projectOptions: function() {
@@ -121,37 +96,10 @@ export default {
                 text: project.name,
             }));
         },
-        computeResourceOptions: function() {
-            const computeResourceOptions = [];
-            for (let computeResourceId in this.computeResources) {
-                if (this.computeResources.hasOwnProperty(computeResourceId)) {
-                    computeResourceOptions.push({
-                        value: computeResourceId,
-                        text: this.computeResources[computeResourceId],
-                    })
-                }
-            }
-            computeResourceOptions.sort((a, b) => a.text.localeCompare(b.text));
-            return computeResourceOptions;
-        },
     },
     methods: {
-        computeResourceChanged: function(selectedComputeResourceId) {
-            // Find application deployment that corresponds to this compute resource
-            let selectedApplicationDeployment = this.applicationDeployments.find(dep => dep.computeHostId === selectedComputeResourceId);
-            if (!selectedApplicationDeployment) {
-                throw new Error("Failed to find application deployment!");
-            }
-            this.appDeploymentId = selectedApplicationDeployment.appDeploymentId;
-        },
     },
     watch: {
-        appInterface: function() {
-            if (this.appInterface) {
-                services.ApplicationInterfaceService.getComputeResources(this.appInterface.applicationInterfaceId)
-                    .then(computeResources => this.computeResources = computeResources);
-            }
-        },
     }
 }
 </script>
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 b590da3..7c2a478 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
@@ -48,16 +48,10 @@ export default {
             type: String,
             required: true
         },
-        resourceHostId: {
-            type: String,
-            required: true
-        }
     },
     data () {
-        const localComputationalResourceScheduling = this.value.clone();
-        localComputationalResourceScheduling.resourceHostId = this.resourceHostId;
         return {
-            localComputationalResourceScheduling: localComputationalResourceScheduling,
+            localComputationalResourceScheduling: this.value.clone(),
             queueDefaults: [],
         }
     },
@@ -116,10 +110,6 @@ export default {
         appDeploymentId: function(appDeploymentId) {
             this.loadQueueDefaults();
         },
-        resourceHostId: function(resourceHostId) {
-            this.localComputationalResourceScheduling.resourceHostId = resourceHostId;
-            this.emitValueChanged();
-        }
     },
     mounted: function() {
         this.loadQueueDefaults();

-- 
To stop receiving notification emails like this one, please contact
['"commits@airavata.apache.org" <co...@airavata.apache.org>'].