Scheduling workflows using the Data Studio REST API
Aperture Data Studio is intended to be invoked from third party schedulers , like Windows Task Scheduler, Cron or even triggered from workflows within other applications.
The method for doing this is to use the Aperture Data Studio REST API to execute a workflow from within a script, and trigger that script from the scheduler application. The script needs to ensure that it handles errors and other possible conditions from the workflow, such as successful completion but taking significantly shorter or longer than expected.
Workflow execution flow
Regardless of language and scheduler used, the logical steps to follow are
Attempt to login Successful Check if the workflow exists and can be executed Successful Execute workflow and wait for it to complete Is the state COMPLETED? Check any other conditions like time to complete or step results All OK Report successful completion Not OK Report workflow execution failure Is the state is FAILED? Report a workflow execution failure Unsuccessful Report workflow readiness failure Unsucessful Report a login failure
Powershell Example
We can use the logic above to run multiple workflows in parallel and chain workflows together to execute after one another. For example, if I wanted to:
- Execute "Workflow 1" and wait until finished then
- Execute "Workflow 2", "Workflow 3" and "Workflow 4" at the same time and wait for those all to finish and then
- Execute "Workflow 5" and "Workflow 6" at the same time and wait for those to finish, and then
- Execute "Workflow 7"
The execution plan would look as shown below, with each set of parallel workflows a separate phase.
We have implemented an example of this in Powershell. The script is attached below and would be executed as shown below.
>Powershell {path}\apertureExecuteWorkflow.ps1 -username {username} -password {password} -phasesWorkflows @(‘Workflow 1’), @(‘Workflow 2’, ‘Workflow 3’, ‘Workflow 4’), @(‘Workflow 5’, ‘Workflow 6’), @(‘Workflow 7’)
Please note that {path} needs to be the full path to the script.
An example execution is shown below.
>Powershell c:\temp\apertureExecuteWorkflow.ps1 -username myTestUser -password myTestPassword123 -phasesWorkflows @('Workflow1'), @('Workflow2A','Workflow2B'), @('Workflow3')
Comments
-
I ran into an error on a production server, where the Execution Policy for Powershell scripts was set to RemoteSigned.
This in theory should allow scripts to run locally, even if they are not signed. See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7 for more details on execution policies.
The Solution was to edit the script locally, simply by adding and removing line at the bottom of the file. You can do this easily in Notepad. Then Windows will recognise the script as local, as opposed to remote.
2