in django_airavata/apps/workspace/views.py [0:0]
def create_experiment(request, app_module_id):
request.active_nav_item = 'dashboard'
# 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:
raise Exception("Failed to load application module data: {}".format(
app_interface.data['detail']))
user_input_values = {}
for app_input in app_interface.data['applicationInputs']:
if (app_input['type'] ==
DataType.URI and app_input['name'] in request.GET):
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 user_storage_sdk.exists(request, data_product):
user_input_values[app_input['name']] = dp_uri
except Exception:
logger.exception(
f"Failed checking data product uri: {dp_uri}", extra={'request': request})
except ValueError:
logger.exception(f"Invalid user file value: {user_file_value}", extra={'request': request})
elif (app_input['type'] == DataType.STRING and
app_input['name'] in request.GET):
name = app_input['name']
user_input_values[name] = request.GET[name]
context = {
'bundle_name': 'create-experiment',
'app_module_id': app_module_id,
'user_input_values': json.dumps(user_input_values)
}
if 'experiment-data-dir' in request.GET:
context['experiment_data_dir'] = request.GET['experiment-data-dir']
template_path = 'django_airavata_workspace/create_experiment.html'
# Apply a custom application template if it exists
custom_template_path, custom_context = get_custom_template(request, app_module_id)
if custom_template_path is not None:
logger.debug(f"Applying custom application template {custom_template_path}")
template_path = custom_template_path
context.update(custom_context)
return render(request, template_path, context)