Python Scripts
Python Scripts
Scripts are used to inject custom Python code at certain positions in the Segna job running process. Any operation is possible as long as it begins and ends in a pandas dataframe.
Configuration
Add and test scripts through the Segna Platform web-app, and attach them on the job run
API or client library.
Creating Scripts
Scripts can be created, viewed, and edited on the Scripts page of the Segna platform. Scripts are written in Python and provide an environment pre-loaded with pandas and NumPy. The input_dataframe variable contains the input data as a pandas DataFrame. Note that after performing your custom script logic, you must assign the output of the script to the output_dataframe variable.
Restrictions
When writing scripts, the pandas and numpy packages are pre-installed. Other packages are restricted, but if there is something else that you need please feel free to let us know!
Using Scripts
Once a script has been created, note its script id as this will be used to attach it to the job run on the start job command.
See the documentation on Running a Job for how to attach the script to the job at the desired position.
Multiple script ids can be provided and the scripts will run in the order given.
Script Positions
Valid script positions are:
"prePivot"
: the script will run after the job data has been imported, but before data pivoting is applied and before column to field matching has run."preColumnMapping"
: the script will run after pivoting has been applied and before column to field matching has run."postClean"
: the script will run after the run job command has been called and before the data is output to the specified output destination.
Updated 5 months ago