Details of the Script Editor
The Python service is currently running Python 3.9.2 (2021-02-19) The R service is currently running R 4.0.2 (2020-06-23)
The Senseforce Python service uses native python integration which makes it extremely reliable and highly performant. Up to 64 scripts can run concurrently. Any additional request above that number is being queued for later execution. Every executed script has its own thread with its own timeout set to 30 min.
In case you experience performance degradation please contact your Senseforce agent.
For performance reasons, there is a limit of 5.000.000 rows per dataset that can be imported to the script editor. If you need more rows consider aggregating them prior to your script.
When selecting a dataset for input the data type of the columns may change after importing. In the following, we will list the transformation to the data types which are available in R/Python.
The following commands are not allowed for security reasons:
By importing .rds or .pickle files to your script you can use R or Python objects in the script.
Clicking Import Dataset or Model in the Data tab will open a window where you can drop a .rds or .pickle file (or search for one with the explorer). Confirm the import after the file was uploaded. The file can be accessed by clicking
next to the Imported variable. Now you should see
next to your imported file - click the
to add the code to your script necessary to access the object stored in the file. Accessing the attributes of the object you imported now should work in the same way as if you would do it in any other coding environment.
Available data types are,
With the result data type you define how the widget should interpret your results. So if you want time to be displayed in a dynamic format depending on the viewed time frame make your result a timestamp (unix timestamp in milliseconds). If you want a fixed time format you can transform them into a string and define them as such. If you want to use your values as a value for the y-axis they need to be numerical (long, integer or double). If you use factors (which represent strings) in R make sure to transform them to a character vector when assigning them to your result variable.
If you plan to use your results in a widget that only takes one value, like the single text widget, bar, or gauge chart, make sure the value you want to display is the first (or only) one in your results.
If the result is supposed to be used in a multi-chart using the auto-generated series feature and text on the x-axis the widget might display the data, not in the way you want it to. For more details please check the section about the widget editor.
You can specify the unit of your result. Later you can use the unit to be displayed in your chart (e.g. in the legend). Decimals are only relevant for displaying results of type double. You can define how many digits are shown in the charts and widgets.
In R, you can use # to mark a line as a comment (or the end of a line).
In Python, you can use # (when the new Python Service is released to your tenant), or you can use single or triple " to mark a line as a comment sometimes.
You can print out a variable content, and check the result in the “Response Tab” of the browser.
Do not forget to delete or comment out all the print() statements after debugging otherwise your code won’t return a valid JSON.