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 2023/02/03 22:37:25 UTC

[airavata-django-portal] branch develop updated: AIRAVATA-3680 Handle experiment not found for given exp id

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 de6bc7c1 AIRAVATA-3680 Handle experiment not found for given exp id
de6bc7c1 is described below

commit de6bc7c10f6236a953b28d07f3671467cf2e3f82
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri Feb 3 17:37:14 2023 -0500

    AIRAVATA-3680 Handle experiment not found for given exp id
---
 .../statistics/ExperimentStatisticsContainer.vue   | 28 +++++++++++++++++-----
 django_airavata/apps/api/exceptions.py             | 11 ++++++++-
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/statistics/ExperimentStatisticsContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/statistics/ExperimentStatisticsContainer.vue
index 618e0b18..f6c2dcea 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/statistics/ExperimentStatisticsContainer.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/statistics/ExperimentStatisticsContainer.vue
@@ -301,7 +301,7 @@
   </div>
 </template>
 <script>
-import { models, services, utils } from "django-airavata-api";
+import { errors, models, services, utils } from "django-airavata-api";
 import { components, notifications } from "django-airavata-common-ui";
 import ExperimentStatisticsCard from "./ExperimentStatisticsCard";
 import ExperimentDetailsView from "./ExperimentDetailsView";
@@ -560,7 +560,7 @@ export default {
       this.hostnameFilterEnabled = false;
       this.loadStatistics();
     },
-    showExperimentDetails(experimentId, tabTitle = null) {
+    async showExperimentDetails(experimentId, tabTitle = null) {
       const expDetailsIndex = this.getExperimentDetailTabsIndex(experimentId);
       if (expDetailsIndex >= 0) {
         // Update tab title in case it is now loaded from a job id and we want
@@ -570,16 +570,32 @@ export default {
         }
         this.selectExperimentDetailsTab(experimentId);
       } else {
-        services.ExperimentService.retrieve({
-          lookup: experimentId,
-        }).then((exp) => {
+        try {
+          const exp = await services.ExperimentService.retrieve(
+            {
+              lookup: experimentId,
+            },
+            { ignoreErrors: true }
+          );
           this.experimentDetailTabs.push({
             tabTitle: tabTitle || exp.experimentName,
             experiment: exp,
           });
           this.selectExperimentDetailsTab(experimentId);
           this.scrollTabsIntoView();
-        });
+        } catch (error) {
+          if (errors.ErrorUtils.isNotFoundError(error)) {
+            notifications.NotificationList.add(
+              new notifications.Notification({
+                type: "WARNING",
+                message: `No experiment exists with experiment id ${experimentId}`,
+                duration: 5,
+              })
+            );
+          } else {
+            utils.FetchUtils.reportError(error);
+          }
+        }
       }
     },
     async showExperimentDetailsForJobId(jobId) {
diff --git a/django_airavata/apps/api/exceptions.py b/django_airavata/apps/api/exceptions.py
index f9f56592..557e7605 100644
--- a/django_airavata/apps/api/exceptions.py
+++ b/django_airavata/apps/api/exceptions.py
@@ -1,6 +1,9 @@
 import logging
 
-from airavata.api.error.ttypes import AuthorizationException
+from airavata.api.error.ttypes import (
+    AuthorizationException,
+    ExperimentNotFoundException
+)
 from django.core.exceptions import ObjectDoesNotExist
 from django.http import JsonResponse
 from rest_framework import status
@@ -24,6 +27,12 @@ def custom_exception_handler(exc, context):
             {'detail': str(exc)},
             status=status.HTTP_403_FORBIDDEN)
 
+    if isinstance(exc, ExperimentNotFoundException):
+        log.warning("ExperimentNotFoundException", exc_info=exc)
+        return Response(
+            {'detail': str(exc)},
+            status=status.HTTP_404_NOT_FOUND)
+
     if isinstance(exc, TTransport.TTransportException):
         log.warning("TTransportException", exc_info=exc)
         return Response(