diff --git a/automate/deploy_mdf_flow.py b/automate/deploy_mdf_flow.py index 03fbcdd7..14528e64 100644 --- a/automate/deploy_mdf_flow.py +++ b/automate/deploy_mdf_flow.py @@ -58,8 +58,8 @@ globus_auth=globus_auth) mdf_flow.update_flow(flow_def=minimus_mdf_flow.flow_def( - smtp_send_credentials=smtp_send_credentials, sender_email=config['sender_email'], + admin_email=config['admin_email'], flow_permissions=config['flow_permissions'], description=description, administered_by=[ diff --git a/automate/mdf_dev_flow_config.json b/automate/mdf_dev_flow_config.json index be2d32c9..4714434a 100644 --- a/automate/mdf_dev_flow_config.json +++ b/automate/mdf_dev_flow_config.json @@ -6,5 +6,6 @@ "urn:globus:groups:id:5fc63928-3752-11e8-9c6f-0e00fd09bf20" ], - "sender_email": "materialsdatafacility@uchicago.edu" + "sender_email": "materialsdatafacility@uchicago.edu", + "admin_email": "bengal1@illinois.edu" } diff --git a/automate/mdf_prod_flow_config.json b/automate/mdf_prod_flow_config.json index be2d32c9..a0666a4a 100644 --- a/automate/mdf_prod_flow_config.json +++ b/automate/mdf_prod_flow_config.json @@ -6,5 +6,7 @@ "urn:globus:groups:id:5fc63928-3752-11e8-9c6f-0e00fd09bf20" ], - "sender_email": "materialsdatafacility@uchicago.edu" + "sender_email": "materialsdatafacility@uchicago.edu", + "admin_email": "blaiszik@uchicago.edu" + } diff --git a/automate/minimus_mdf_flow.py b/automate/minimus_mdf_flow.py index c0aefd27..7625c804 100644 --- a/automate/minimus_mdf_flow.py +++ b/automate/minimus_mdf_flow.py @@ -2,8 +2,40 @@ from globus_automate_flow import GlobusAutomateFlowDef +def email_submission_to_admin(sender_email, admin_email): + return { + "EmailSubmission": { + "Type": "Action", + "ActionUrl": "https://actions.globus.org/notification/notify", + "ExceptionOnActionFailure": True, + "Parameters": { + "body_mimetype": "text/html", + "sender": sender_email, + "destination": admin_email, + "subject": "Materials Data Facility Dataset Submission", + "body_template": "A new dataset has been submitted. $submission_json", + "body_variables": { + "$submission_json.=": "$.dataset_mdata" + }, + "notification_method": "any", + "notification_priority": "high", + "send_credentials": [ + { + "credential_method": "email", + "credential_type": "ses", + "credential_value.$": "$._private_email_credentials", + } + ], + "__Private_Parameters": ["send_credentials"], + }, + "Next": "Check Metadata Only" + }, + } + + + def check_update_metadata_only(): - return{ + return { "Check Metadata Only": { "Comment": "Checks whether flow just updates the metadata", "Type": "Choice", @@ -11,10 +43,10 @@ def check_update_metadata_only(): { "Variable": "$.update_metadata_only", "BooleanEquals": True, - "Next": "ChooseCuration" + "Next": "ChooseCuration", } ], - "Default": "CreateDestinationDir" + "Default": "CreateDestinationDir", } } @@ -22,7 +54,7 @@ def check_update_metadata_only(): def file_transfer_steps(): """ Steps to transfer user data to MDF repository: - * Add a temporary write permission to the repo so we can execute the transfer + * Add a temporary write permission to the repo, so we can execute the transfer as the submitting user * Execute the transfer using runAs * Remove the temporary write permission @@ -41,11 +73,10 @@ def file_transfer_steps(): "Catch": [ { "ErrorEquals": ["ActionFailedException", "States.Runtime"], - "Next": "FailUserPermission" + "Next": "FailUserPermission", } ], - - "Next": "UserPermissions" + "Next": "UserPermissions", }, "UserPermissions": { "Comment": "Temporarily add write permissions for the submitting user", @@ -58,17 +89,16 @@ def file_transfer_steps(): "path.$": "$.user_transfer_inputs.transfer_items[0].destination_path", "principal_type": "identity", "principal.$": "$.user_transfer_inputs.submitting-user-id", - "permissions": "rw" + "permissions": "rw", }, "ResultPath": "$.UserPermissionResult", "Catch": [ { "ErrorEquals": ["ActionFailedException", "States.Runtime"], - "Next": "FailUserPermission" + "Next": "FailUserPermission", } ], - - "Next": "UserTransfer" + "Next": "UserTransfer", }, "UserTransfer": { "Comment": "Copy from user's endpoint to organization's dataset destination", @@ -80,10 +110,10 @@ def file_transfer_steps(): "source_endpoint_id.$": "$.user_transfer_inputs.source_endpoint_id", "destination_endpoint_id.$": "$.user_transfer_inputs.destination_endpoint_id", "label.$": "$.user_transfer_inputs.label", - "transfer_items.$": "$.user_transfer_inputs.transfer_items" + "transfer_items.$": "$.user_transfer_inputs.transfer_items", }, "ResultPath": "$.UserTransferResult", - "Next": "UndoUserPermissions" + "Next": "UndoUserPermissions", }, "UndoUserPermissions": { "Comment": "Remove temporary write permissions for the submitting user", @@ -93,16 +123,16 @@ def file_transfer_steps(): "Parameters": { "operation": "DELETE", "endpoint_id.$": "$.user_transfer_inputs.destination_endpoint_id", - "rule_id.$": "$.UserPermissionResult.details.access_id" + "rule_id.$": "$.UserPermissionResult.details.access_id", }, "ResultPath": "$.UndoUserPermissionResult", "Catch": [ { "ErrorEquals": ["ActionFailedException", "States.Runtime"], - "Next": "FailUserPermission" + "Next": "FailUserPermission", } ], - "Next": "CheckUserTransfer" + "Next": "CheckUserTransfer", }, "CheckUserTransfer": { "Type": "Choice", @@ -110,33 +140,33 @@ def file_transfer_steps(): { "Variable": "$.UserTransferResult.status", "StringEquals": "SUCCEEDED", - "Next": "ChooseCuration" + "Next": "ChooseCuration", } ], - "Default": "FailUserTransfer" + "Default": "FailUserTransfer", }, "FailUserTransfer": { "Type": "ExpressionEval", "Parameters": { "title": "MDF Submission Failed", - "message.=": "'Your MDF submission ' + `$.source_id` + ' failed during transfer, please try again or contact materialsdatafacility@uchicago.edu:\n' + `$.UserTransferResult.details`" + "message.=": "'Your MDF submission ' + `$.source_id` + ' failed during transfer, please try again or contact materialsdatafacility@uchicago.edu:\n' + `$.UserTransferResult.details`", }, "ResultPath": "$.FinalState", - "Next": "NotifyUserEnd" + "Next": "NotifyUserEnd", }, "FailUserPermission": { "Type": "ExpressionEval", "Parameters": { "title": "MDF Permission Settings Failed", - "message.=": "'Your MDF submission ' + `$.source_id` + ' failed to transfer, please try again or contact materialsdatafacility@uchicago.edu:\n' + `$.UserPermissionResult.details`" + "message.=": "'Your MDF submission ' + `$.source_id` + ' failed to transfer, please try again or contact materialsdatafacility@uchicago.edu:\n' + `$.UserPermissionResult.details`", }, "ResultPath": "$.FinalState", - "Next": "NotifyUserEnd" + "Next": "NotifyUserEnd", }, } -def curation_steps(sender_email): +def curation_steps(sender_email, admin_email): """ Steps for allowing an administrator to curate submissions: * Check to see if curation has been requested @@ -151,10 +181,10 @@ def curation_steps(sender_email): { "Variable": "$.curation_input", "BooleanEquals": False, - "Next": "NeedDOI" + "Next": "NeedDOI", } ], - "Default": "SendCurationEmail" + "Default": "SendCurationEmail", }, "SendCurationEmail": { "Type": "Action", @@ -164,26 +194,24 @@ def curation_steps(sender_email): "Parameters": { "body_mimetype": "text/html", "sender": sender_email, - "destination": "blaiszik@uchicago.edu", - # "destination": "materialsdatafacility@uchicago.edu", + "destination": admin_email, "subject": "Materials Data Facility Dataset Curation Request", "body_template": "Please either Approve or Deny the dataset publication request here: $landing_page_url", "body_variables": { "landing_page_url.=": "'https://actions.globus.org/weboption/landing_page/' + `$._context.action_id`" - }, "notification_method": "any", + }, + "notification_method": "any", "notification_priority": "high", "send_credentials": [ { "credential_method": "email", "credential_type": "ses", - "credential_value.$": "$._private_email_credentials" + "credential_value.$": "$._private_email_credentials", } ], - "__Private_Parameters": [ - "send_credentials" - ] + "__Private_Parameters": ["send_credentials"], }, - "Next": "CurateSubmission" + "Next": "CurateSubmission", }, "CurateSubmission": { "Type": "Action", @@ -198,24 +226,25 @@ def curation_steps(sender_email): "header_icon_link": "https://materialsdatafacility.org", "header_text": "Curate an MDF Dataset", "page_title": "Materials Data Facility", - "preamble_text.=": "'A new dataset has been submitted. ' + `$.mdf_portal_link` +' Please review it to allow processing to continue.'"}, + "preamble_text.=": "'A new dataset has been submitted. ' + `$.mdf_portal_link` +' Please review it to allow processing to continue.'", + }, "options": [ { "name": "accepted", "description": "Accept dataset", "url_suffix.=": "`$._context.action_id` + '_approve'", - "completed_message": "