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 2020/05/21 19:39:28 UTC

[airavata-django-portal] branch develop updated: AIRAVATA-3334 Allow passing data product URIs as query params to create experiment

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 98fb03e  AIRAVATA-3334 Allow passing data product URIs as query params to create experiment
     new 3498335  Merge branch 'AIRAVATA-3334-allow-passing-data-product-uris-for-inputs-to-crea' into develop
98fb03e is described below

commit 98fb03e663ce1f7dfe14ddc0e280182633701d09
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu May 21 15:38:49 2020 -0400

    AIRAVATA-3334 Allow passing data product URIs as query params to create experiment
---
 django_airavata/apps/workspace/views.py | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/django_airavata/apps/workspace/views.py b/django_airavata/apps/workspace/views.py
index 80c488d..c0da11e 100644
--- a/django_airavata/apps/workspace/views.py
+++ b/django_airavata/apps/workspace/views.py
@@ -1,6 +1,7 @@
 
 import json
 import logging
+from urllib.parse import urlparse
 
 from django.contrib.auth.decorators import login_required
 from django.shortcuts import render
@@ -74,6 +75,8 @@ def create_experiment(request, app_module_id):
 
     # User input files can be passed as query parameters
     # <input name>=<path/to/user_file>
+    # and also as data product URIs
+    # <input name>=<data product URI>
     app_interface = ApplicationModuleViewSet.as_view(
         {'get': 'application_interface'})(request, app_module_id=app_module_id)
     if app_interface.status_code != 200:
@@ -83,11 +86,26 @@ def create_experiment(request, app_module_id):
     for app_input in app_interface.data['applicationInputs']:
         if (app_input['type'] ==
                 DataType.URI and app_input['name'] in request.GET):
-            user_file_path = request.GET[app_input['name']]
-            data_product_uri = data_products_helper.user_file_exists(
-                request, user_file_path)
-            if data_product_uri is not None:
-                user_input_files[app_input['name']] = data_product_uri
+            user_file_value = request.GET[app_input['name']]
+            try:
+                user_file_url = urlparse(user_file_value)
+                if user_file_url.scheme == 'airavata-dp':
+                    dp_uri = user_file_value
+                    try:
+                        data_product = request.airavata_client.getDataProduct(
+                            request.authz_token, dp_uri)
+                        if data_products_helper.exists(request, data_product):
+                            user_input_files[app_input['name']] = dp_uri
+                    except Exception as e:
+                        logger.exception(
+                            "Failed checking data product uri: {dp_uri}")
+                else:
+                    data_product_uri = data_products_helper.user_file_exists(
+                        request, user_file_url.path)
+                    if data_product_uri is not None:
+                        user_input_files[app_input['name']] = data_product_uri
+            except ValueError as e:
+                logger.exception(f"Invalid user file value: {user_file_value}")
     context = {
         'bundle_name': 'create-experiment',
         'app_module_id': app_module_id,