Forward Parameters to Machine Learning Script
In order to use the full power of Machine Learning Scripts in combination with Action Flows, the forwarding of parameters is essential. That's the reason we provide you with an Action Flow Snippet that integrates desired parameter of the Action Flow into the ML tool automatically.
Follow the step-by-step guide below to implement this solution for your Action Flows snippet.
Sample Action Flow
The image below shows an Action Flow snippet which:
Creates JSON data structure to forward parameters
Trigger ML script with parameters
Configuring an Action Flow
Below you will find the step-by-step guide for configuring each module of the Action Flow above.
0. Trigger the Action Flow
Note
You can integrate any trigger sequence, e.g. Slack, Email, Celonis, etc.
An example for a Slack trigger sequence can be found at Trigger Machine Learning Script.
1. Customize Variables
This is the most important module in this Action Flow where we have to adjust all the data specific to your team and account like the team domain or an Application Key with the right permissions
Configuration:
Action Flows Module: Tools
Action: Set multiple variables
teamDomain: Enter your teamdomain, e.g. demo-action-flows
env: Enter your cluster, e.g. try, eu-1...
AppKey: e.g.:
GjV6ODBvghgv6r76r0YzkyLTkxZwjbflqjwhebfljwhebfqjhebfwlV5TEVCcjMzAHBFK0F8TXdGBTlqBWFlsVPN
notebookId: This will be added to the Template later when creating a ML App / adding Scripts to an existing ML App.
executionFileName: Name of the ML Script to be triggered, e.g. trigger_MLScript.ipynb
2. Pass Parameters as JSON
This module creates a JSON file that is sent as a variable in the HTML request body to be used in our ML script.
Note
The API endpoint that forwards parameters to the ML workbench script has a maximum size limit of 96 KB. This is a hard limit and cannot be changed.
This limit is typically exceeded when trying to pass files to the ML Workbench. In this case, we recommend passing the parameters of the file metadata (i.e., file id, file path, download url, etc.) and then making an API call within the ML Workbench script to retrieve the file(s).
Configuration:
Action Flows Module: JSON
Action: Create JSON
Parameters, e.g.:
JSON file for Generator
{ "parameter1": "test1", "parameter2": "test2", "parameter3": "test3" }
Possible Data Types
You can pass parameters of any type that can be handled by standard Python or libraries, such as HTML, JSON, str, int, csv-files, txt-files, etc.
3. Trigger ML Script
This module sends a POST Request to our ML API and triggers the previously defined ML script.
Important
You do not have to change anything in this module.
Configuration:
Action Flows Module: HTTP
Action: Make a Request
URL: https://{{teamDomain}}.{{env}}.celonis.cloud/machine-learning/api/executions
Method: POST
Headers:
Name: Authorization
Value: AppKey {{AppKey}}
Body type: Raw
Content type: JSON (application/json)
Request content:
{ "notebookId": "{{notebookId}}", "executionFileName":"{{executionFileName}}", "params": {{json}} }
ML Script: Adding a ML Script to Trigger
Import the script in a new or existing ML App. The ML script will run your pre-defined Python logic and can make use of the parameters that you have forwarded.
Creating your own Logic
The script includes further documentation on how to ensure the successful execution. Make sure to follow these steps as well.
If you apply your own logic and parameters, make sure to code robustly and test the script thoroughly. If an error occurs, the backend does not give an indicator what the error was.
Navigate to the Machine Learning tab.
Open existing App or create a new one.
Delay
When creating a new ML App, it can take a few minutes up to one hour until it can be opened.
Import the Script provided above.
Make sure it is uploaded successfully and displayed in the section on the left.
Copy the
notebookId
to the clipboard and add it to the variables as the value for the notebookId in the "Customize Variables" module in the Triggering Action Flow.
Mandatory Step for Parameters
When developing your Python code, you can define default values for the parameters to run the script by itself and test your logic.
IMPORTANT Tag the cell of your Notebook with the Tag "parameters" where you set your default values with the same data type that you will pass from the Action Flow. While developing and running the code from Jupyter, these values will be used. When you are calling the Notebook from the Action Flow, the default values will be overwritten by the ones passed by the Action Flow.
Downloading Action Flow blueprints
To download blueprints for Action Flows, go to Marketplace. In the Marketplace page for your Action Flow, click the Download button to get the blueprint.
Blueprints can be imported into your Celonis Platform Team so that you can quickly make the required changes without needing to build the Action Flow from scratch.
Potential Enhancements
You could integrate other apps into the Action Flow Snippet to forward parameters with data from Celonis, Google Sheets, SAP, etc.
Possible Use Cases
Run complex Python scripts in Action Flows and use the results for different use cases.
Integrate ML capabilities in your Action Flows.
Potential Alternatives
You could replace the triggering Slack module with a Scheduling to run the ML Script frequently.
You could also replace the Slack module at the end with a messaging module of your choice such as Email or Microsoft Teams.