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/01/25 18:01:50 UTC
[airavata-django-portal] 02/06: AIRAVATA-3570 Refactor compute selector to be usable standalone
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
commit 08866cad902a8ce92c4da3966b1c6dcabb6c92f3
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Jan 24 15:11:44 2022 -0500
AIRAVATA-3570 Refactor compute selector to be usable standalone
---
.../ExperimentComputeResourceSelector.vue | 23 +++++++++++++++
.../GroupResourceProfileSelector.vue | 2 +-
.../js/web-components/store.js | 34 ++++++++++++++++++----
3 files changed, 52 insertions(+), 7 deletions(-)
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/ExperimentComputeResourceSelector.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/ExperimentComputeResourceSelector.vue
index 1121fe0..5a06d88 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/ExperimentComputeResourceSelector.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/ExperimentComputeResourceSelector.vue
@@ -13,6 +13,17 @@ import ComputeResourceSelector from "./ComputeResourceSelector.vue";
export default {
name: "experiment-compute-resource-selector",
+ props: {
+ applicationModuleId: {
+ type: String,
+ required: true,
+ },
+ },
+ data() {
+ return {
+ initialized: false,
+ };
+ },
store: store,
components: {
ComputeResourceSelector,
@@ -22,6 +33,7 @@ export default {
// compute resources for the current set of application deployments
"computeResources",
"resourceHostId",
+ "groupResourceProfileId",
]),
},
methods: {
@@ -32,6 +44,17 @@ export default {
});
},
},
+ watch: {
+ groupResourceProfileId(groupResourceProfileId) {
+ if (!this.initialized && groupResourceProfileId) {
+ this.$store.dispatch("initializeComputeResources", {
+ applicationModuleId: this.applicationModuleId,
+ groupResourceProfileId: groupResourceProfileId,
+ });
+ this.initialized = true;
+ }
+ },
+ },
};
</script>
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/GroupResourceProfileSelector.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/GroupResourceProfileSelector.vue
index e73e772..b93fba9 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/GroupResourceProfileSelector.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/GroupResourceProfileSelector.vue
@@ -37,7 +37,7 @@ export default {
},
},
store: store,
- async mounted() {
+ async created() {
await this.$store.dispatch("initializeGroupResourceProfileId", {
groupResourceProfileId: this.value,
});
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 4371881..68d1a13 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
@@ -29,9 +29,12 @@ export const mutations = {
updateGroupResourceProfileId(state, { groupResourceProfileId }) {
state.groupResourceProfileId = groupResourceProfileId;
},
- updateResourceHostId(state, { resourceHostId }) {
+ updateExperimentResourceHostId(state, { resourceHostId }) {
state.experiment.userConfigurationData.computationalResourceScheduling.resourceHostId = resourceHostId;
},
+ updateResourceHostId(state, { resourceHostId }) {
+ state.resourceHostId = resourceHostId;
+ },
updateQueueName(state, { queueName }) {
state.experiment.userConfigurationData.computationalResourceScheduling.queueName = queueName;
},
@@ -281,7 +284,19 @@ export const actions = {
dispatch("applyBatchQueueResourcePolicy");
}
},
- async initializeResourceHostId({ commit, dispatch, getters }) {
+ async initializeComputeResources(
+ { commit, dispatch },
+ { applicationModuleId, groupResourceProfileId }
+ ) {
+ commit("setApplicationModuleId", { applicationModuleId });
+
+ if (groupResourceProfileId) {
+ await dispatch("loadApplicationDeployments");
+ await dispatch("loadAppDeploymentQueues");
+ await dispatch("applyGroupResourceProfile");
+ }
+ },
+ async initializeResourceHostId({ commit, dispatch, getters, state }) {
// if there isn't a selected compute resource or there is but it isn't in
// the list of app deployments, set a default one
// Returns true if the resourceHostId changed
@@ -290,9 +305,15 @@ export const actions = {
!getters.computeResources.find((crid) => crid === getters.resourceHostId)
) {
const defaultResourceHostId = await dispatch("getDefaultResourceHostId");
- commit("updateResourceHostId", {
- resourceHostId: defaultResourceHostId,
- });
+ if (state.experiment) {
+ commit("updateExperimentResourceHostId", {
+ resourceHostId: defaultResourceHostId,
+ });
+ } else {
+ commit("updateResourceHostId", {
+ resourceHostId: defaultResourceHostId,
+ });
+ }
return true;
}
return false;
@@ -493,7 +514,7 @@ export const getters = {
state.experiment.userConfigurationData.computationalResourceScheduling
? state.experiment.userConfigurationData.computationalResourceScheduling
.resourceHostId
- : null,
+ : state.resourceHostId,
computeResources: (state) =>
state.applicationDeployments.map((dep) => dep.computeHostId),
applicationDeployment: (state, getters) => {
@@ -685,6 +706,7 @@ export default new Vuex.Store({
// Lazy state fields that will be copied to the experiment once it is loaded
queueName: null,
groupResourceProfileId: null,
+ resourceHostId: null,
},
mutations,
actions,