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/09/03 23:53:43 UTC
[airavata-django-portal-sdk] branch
AIRAVATA-3346-implement-remote-fs-abstraction-of-user-storage updated:
AIRAVATA-3346: AIRAVATA-3346 WIP
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch AIRAVATA-3346-implement-remote-fs-abstraction-of-user-storage
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git
The following commit(s) were added to refs/heads/AIRAVATA-3346-implement-remote-fs-abstraction-of-user-storage by this push:
new e8f1e4f AIRAVATA-3346: AIRAVATA-3346 WIP
e8f1e4f is described below
commit e8f1e4fc2506f38b1fde882e540a47f75aeb3045
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Sep 3 19:53:27 2020 -0400
AIRAVATA-3346: AIRAVATA-3346 WIP
---
airavata_django_portal_sdk/user_storage.py | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/airavata_django_portal_sdk/user_storage.py b/airavata_django_portal_sdk/user_storage.py
index c57cd64..f3000dd 100644
--- a/airavata_django_portal_sdk/user_storage.py
+++ b/airavata_django_portal_sdk/user_storage.py
@@ -18,6 +18,7 @@ from airavata.model.data.replica.ttypes import (DataProductModel,
ReplicaPersistentType)
import copy
+import requests
logger = logging.getLogger(__name__)
@@ -107,14 +108,35 @@ def move_input_file_from_filepath(
def open_file(request, data_product):
"Return file object for replica if it exists in user storage."
- path = _get_replica_filepath(data_product)
- return _Datastore().open(data_product.ownerName, path)
+ if getattr(settings, 'GATEWAY_DATA_STORE_REMOTE_API', None) is not None:
+ headers = {
+ 'Authorization': f'Bearer {request.authz_token.accessToken}'}
+ r = requests.get(
+ f'{settings.GATEWAY_DATA_STORE_REMOTE_API}/download',
+ headers=headers,
+ params={'data-product-uri': data_product.productUri})
+ r.raise_for_status()
+ return r.content
+ else:
+ path = _get_replica_filepath(data_product)
+ return _Datastore().open(data_product.ownerName, path)
def exists(request, data_product):
"Return True if replica for data_product exists in user storage."
- path = _get_replica_filepath(data_product)
- return _Datastore().exists(data_product.ownerName, path)
+ if getattr(settings, 'GATEWAY_DATA_STORE_REMOTE_API', None) is not None:
+ headers = {
+ 'Authorization': f'Bearer {request.authz_token.accessToken}'}
+ r = requests.get(
+ f'{settings.GATEWAY_DATA_STORE_REMOTE_API}/data-products/',
+ headers=headers,
+ params={'product-uri': data_product.productUri})
+ r.raise_for_status()
+ data = r.json()
+ return data['downloadURL'] is not None
+ else:
+ path = _get_replica_filepath(data_product)
+ return _Datastore().exists(data_product.ownerName, path)
def dir_exists(request, path):