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/09/27 19:00:33 UTC
[airavata-cookiecutter-django-output-view] 04/10: user_storage module example code
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airavata-cookiecutter-django-output-view.git
commit da284f3fcdd48c09fc1c0dc08a134f8cf56d8cbd
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Jun 2 11:51:30 2021 -0400
user_storage module example code
---
.../{{cookiecutter.project_slug}}.py | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/{{cookiecutter.custom_django_app_module_name}}/{{cookiecutter.output_views_directory_name}}/{{cookiecutter.project_slug}}.py b/{{cookiecutter.custom_django_app_module_name}}/{{cookiecutter.output_views_directory_name}}/{{cookiecutter.project_slug}}.py
index 3077383..188769f 100644
--- a/{{cookiecutter.custom_django_app_module_name}}/{{cookiecutter.output_views_directory_name}}/{{cookiecutter.project_slug}}.py
+++ b/{{cookiecutter.custom_django_app_module_name}}/{{cookiecutter.output_views_directory_name}}/{{cookiecutter.project_slug}}.py
@@ -4,6 +4,9 @@ import io
from django.template.loader import render_to_string
{% endif %}
+from airavata_django_portal_sdk import user_storage
+
+
class {{ cookiecutter.output_view_provider_class_name }}:
display_type = "{{ cookiecutter.output_view_display_type }}"
# As a performance optimization, the output view provider can be invoked
@@ -14,6 +17,32 @@ class {{ cookiecutter.output_view_provider_class_name }}:
name = "{{ cookiecutter.project_name }}"
def generate_data(self, request, experiment_output, experiment,{% if "single" in cookiecutter.number_of_output_files %} output_file=None,{% else %} output_files=None,{% endif %} **kwargs):
+
+ # Use `output_file` or `output_files` to read from the output file(s).
+ # See https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects
+ # for how to read from file objects. For example, to read the entire file, use:
+ #
+ # entire_file = output_file.read()
+
+
+ # Example code: user_storage module
+ # To find other files in the experiment data directory, use the
+ # user_storage module of the airavata_django_portal_sdk. You can use the
+ # following to list the files and directories in the experiment data
+ # directory:
+ #
+ # dirs, files = user_storage.list_experiment_dir(request, experiment.experimentId)
+ #
+ # The 'files' variable is a list of dictionaries, each one will have a
+ # 'data-product-uri' key. Use the data-product-uri to open the file:
+ #
+ # data_product_uri = files[0]['data-product-uri']
+ # data = user_storage.open_file(request, data_product_uri=data_product_uri)
+ #
+ # See https://airavata-django-portal-sdk.readthedocs.io/en/latest/#module-user_storage
+ # for more information.
+
+
{% if cookiecutter.output_view_display_type == "link" %}
label = "Link to Google"
url = "https://google.com"