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/05/03 22:48:48 UTC

[airavata-django-portal-sdk] branch mft-integration updated: AIRAVATA-3362 Make sure experiment storage path is relative to experiment data dir

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

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


The following commit(s) were added to refs/heads/mft-integration by this push:
     new e14b830  AIRAVATA-3362 Make sure experiment storage path is relative to experiment data dir
e14b830 is described below

commit e14b8300a9eb8bef2c43ca12b6f7677a2520553c
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon May 3 18:48:34 2021 -0400

    AIRAVATA-3362 Make sure experiment storage path is relative to experiment data dir
---
 airavata_django_portal_sdk/user_storage/api.py                   | 9 +++++++--
 .../user_storage/backends/django_filesystem_provider.py          | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index 87289f4..51f1279 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -507,12 +507,15 @@ def list_experiment_dir(request, experiment_id, path="", storage_resource_id=Non
     experiment = request.airavata_client.getExperiment(
         request.authz_token, experiment_id)
     backend = get_user_storage_provider(request, storage_resource_id=storage_resource_id)
-    exp_data_path = experiment.userConfigurationData.experimentDataDir
-    exp_data_path = os.path.join(exp_data_path, path)
+    exp_data_dir = experiment.userConfigurationData.experimentDataDir
+    exp_data_path = os.path.join(exp_data_dir, path)
     # Implement username override with exp_owner
     # exp_owner = experiment.userName
     if backend.exists(exp_data_path):
         directories, files = backend.get_metadata(exp_data_path)
+        for directory in directories:
+            # construct the relative path of the directory within the experiment data dir
+            directory['path'] = os.path.relpath(directory['resource_path'], exp_data_dir)
         # for each file, lookup or register a data product and enrich the file
         # metadata with data-product-uri and mime-type
         for file in files:
@@ -527,6 +530,8 @@ def list_experiment_dir(request, experiment_id, path="", storage_resource_id=Non
                 mime_type = data_product.productMetadata['mime-type']
             file['data-product-uri'] = data_product_uri
             file['mime_type'] = mime_type
+            # construct the relative path of the file within the experiment data dir
+            file['path'] = os.path.relpath(file['resource_path'], exp_data_dir)
             # TODO: remove this, there's no need for hidden files
             file['hidden'] = False
         return directories, files
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 16845ca..5fd635e 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
@@ -47,7 +47,7 @@ class DjangoFileSystemProvider(UserStorageProvider):
                     {
                         "name": d,
                         "path": datastore.rel_path(dpath),
-                        "resource_path": datastore.rel_path(dpath),
+                        "resource_path": datastore.path(dpath),
                         "created_time": created_time,
                         "size": size,
                     }
@@ -66,7 +66,7 @@ class DjangoFileSystemProvider(UserStorageProvider):
                     {
                         "name": f,
                         "path": datastore.rel_path(full_path),
-                        "resource_path": datastore.rel_path(full_path),
+                        "resource_path": full_path,
                         "created_time": created_time,
                         "size": size,
                     }