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 2021/08/04 16:24:42 UTC

[airavata-django-portal-sdk] branch master updated (5a0a08a -> c121c9e)

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

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


    from 5a0a08a  Bump version to 1.2.dev1
     new 9c3be01  AIRAVATA-3420 Remove redundant parameter
     new 4e977db  AIRAVATA-3420 Utility method to get the default storage id
     new cfac345  AIRAVATA-3420 Change remote API implementation of get_download_url to resolve to local URL and stream from remote server
     new c121c9e  Bump version to 1.2.dev2

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 airavata_django_portal_sdk/user_storage/api.py     | 44 +++++++++-------------
 .../backends/django_filesystem_provider.py         |  9 ++---
 setup.py                                           |  2 +-
 3 files changed, 22 insertions(+), 33 deletions(-)

[airavata-django-portal-sdk] 01/04: AIRAVATA-3420 Remove redundant parameter

Posted by ma...@apache.org.
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-sdk.git

commit 9c3be011514e94142c2dece0eb6dd9c838caf0b6
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Aug 4 12:04:01 2021 -0400

    AIRAVATA-3420 Remove redundant parameter
---
 .../user_storage/backends/django_filesystem_provider.py          | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py b/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py
index fcb6f73..75ea981 100644
--- a/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py
+++ b/airavata_django_portal_sdk/user_storage/backends/django_filesystem_provider.py
@@ -11,14 +11,13 @@ logger = logging.getLogger(__name__)
 
 
 class DjangoFileSystemProvider(UserStorageProvider):
-    def __init__(self, authz_token, resource_id, context=None, directory=None, storage_resource_id=None, **kwargs):
+    def __init__(self, authz_token, resource_id, context=None, directory=None, **kwargs):
         super().__init__(authz_token, resource_id, context=context, **kwargs)
         self.directory = directory
-        self.storage_resource_id = resource_id
 
     def save(self, path, file, name=None, content_type=None):
         full_path = self.datastore.save(path, file, name=name)
-        return self.storage_resource_id, full_path
+        return self.resource_id, full_path
 
     def open(self, resource_path):
         return self.datastore.open(resource_path)
@@ -107,7 +106,7 @@ class DjangoFileSystemProvider(UserStorageProvider):
         # Special case: handle creating user's home directory
         if resource_path == '' and not datastore.exists(''):
             datastore.create_user_dir('')
-            return self.storage_resource_id, datastore.path(resource_path)
+            return self.resource_id, datastore.path(resource_path)
         if not datastore.exists(resource_path):
             raise ObjectDoesNotExist(f"User resource_path does not exist {resource_path}")
         valid_dir_names = []
@@ -119,7 +118,7 @@ class DjangoFileSystemProvider(UserStorageProvider):
         # Make sure path is unique if it already exists
         final_path = datastore.get_available_name(final_path)
         datastore.create_user_dir(final_path)
-        return self.storage_resource_id, datastore.path(final_path)
+        return self.resource_id, datastore.path(final_path)
 
     def create_symlink(self, source_path, dest_path):
         datastore = self.datastore

[airavata-django-portal-sdk] 03/04: AIRAVATA-3420 Change remote API implementation of get_download_url to resolve to local URL and stream from remote server

Posted by ma...@apache.org.
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-sdk.git

commit cfac345e7a6686eac61cea1ceb0fd4bb4c1503f6
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Aug 4 12:05:55 2021 -0400

    AIRAVATA-3420 Change remote API implementation of get_download_url to resolve to local URL and stream from remote server
---
 airavata_django_portal_sdk/user_storage/api.py | 39 ++++++++------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index 7b0b85f..c015cd1 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -202,16 +202,8 @@ def get_download_url(request, data_product=None, data_product_uri=None, force_do
     if data_product is None:
         data_product = _get_data_product(request, data_product_uri)
     if _is_remote_api():
-        resp = _call_remote_api(
-            request,
-            "/data-products/",
-            params={'product-uri': data_product.productUri},
-            raise_for_status=False)
-        if resp.status_code == HTTPStatus.NOT_FOUND:
-            return None
-        resp.raise_for_status()
-        data = resp.json()
-        return data['downloadURL']
+        # Build a local /sdk/download-file URL that will stream the file from the remote server
+        return _build_download_url(request, data_product, force_download=force_download, mime_type=mime_type)
     storage_resource_id, path = _get_replica_resource_id_and_filepath(data_product)
     backend = get_user_storage_provider(request,
                                         owner_username=data_product.ownerName,
@@ -221,28 +213,21 @@ def get_download_url(request, data_product=None, data_product_uri=None, force_do
     else:
         # if backend doesn't provide a download url, then use default one
         # that uses backend to read the file
-        params = {"data-product-uri": data_product.productUri}
-        if force_download:
-            params['download'] = ''
-        if mime_type is not None:
-            params['mime-type'] = mime_type
-        return request.build_absolute_uri(f"{reverse('airavata_django_portal_sdk:download_file')}?{urlencode(params)}")
+        return _build_download_url(request, data_product, force_download=force_download, mime_type=mime_type)
+
+
+def _build_download_url(request, data_product, force_download=False, mime_type=None):
+    params = {"data-product-uri": data_product.productUri}
+    if force_download:
+        params['download'] = ''
+    if mime_type is not None:
+        params['mime-type'] = mime_type
+    return request.build_absolute_uri(f"{reverse('airavata_django_portal_sdk:download_file')}?{urlencode(params)}")
 
 
 def get_lazy_download_url(request, data_product=None, data_product_uri=None):
     if data_product is None:
         data_product = _get_data_product(request, data_product_uri)
-    if _is_remote_api():
-        resp = _call_remote_api(
-            request,
-            "/data-products/",
-            params={'product-uri': data_product.productUri},
-            raise_for_status=False)
-        if resp.status_code == HTTPStatus.NOT_FOUND:
-            return None
-        resp.raise_for_status()
-        data = resp.json()
-        return data['downloadURL']
     # /download will call get_download_url and redirect to it
     return request.build_absolute_uri(reverse("airavata_django_portal_sdk:download") + "?" +
                                       urlencode({"data-product-uri": data_product.productUri}))

[airavata-django-portal-sdk] 02/04: AIRAVATA-3420 Utility method to get the default storage id

Posted by ma...@apache.org.
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-sdk.git

commit 4e977dbb3d869fb7039c4b9d0dfcca7c539e0861
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Aug 4 12:05:23 2021 -0400

    AIRAVATA-3420 Utility method to get the default storage id
    
    Storage id is set on the ExperimentModel so provide a proper function to get it.
---
 airavata_django_portal_sdk/user_storage/api.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index 252ce0d..7b0b85f 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -74,6 +74,11 @@ def get_user_storage_provider(request, owner_username=None, storage_resource_id=
     return instance
 
 
+def get_default_storage_resource_id(request):
+    backend = get_user_storage_provider(request)
+    return backend.storage_resource_id
+
+
 def save(request, path, file, name=None, content_type=None, storage_resource_id=None, experiment_id=None):
     """
     Save file in path in the user's storage and return DataProduct. If

[airavata-django-portal-sdk] 04/04: Bump version to 1.2.dev2

Posted by ma...@apache.org.
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-sdk.git

commit c121c9e5fe566769b44f337cbc82238bedb56cbf
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Aug 4 12:21:48 2021 -0400

    Bump version to 1.2.dev2
---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 9b6babb..373c910 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ def read(fname):
 
 setup(
     name="airavata-django-portal-sdk",
-    version="1.2.dev1",
+    version="1.2.dev2",
     url="https://github.com/apache/airavata-django-portal-sdk",
     author="Apache Software Foundation",
     author_email="dev@airavata.apache.org",