Return Values

The result of a REST API for Embedded Python Execution function endpoint is a JSON representation of the value returned by the Python function of the specified script.

The Python function in the script must return a JSON serializable value. The supported values are the following:
  • boolean
  • dict
  • enum, IntEnum
  • float
  • int
  • list
  • pandas.DataFrame
  • str
  • tuple

PNG images rendered in the script are included in the response. In the JSON returned, the IMAGE field contains the bytes of the PNG image and the DATA field contains the return value of the function.

Note:

An output limit exists on the length function for REST API and SQL APIs for embedded Python execution. A query on the length function with a length of more than 5000 will result in an error with error code 1024 and the error message "Output exceeds maximum length 5000". The limit is set on the len() result of the returning python object. For example, len() of a pandas.DataFrame is the number of rows, len() of a list is the length of the list, etc. If pandas.DataFrame is returned, it cannot have more than 5000 rows. If a list is returned, it should not contain more than 5000 items. This limit can be extended by updating the OML_OUTPUT_SZLIMIT in a %script paragraph:
%script

EXEC sys.pyqconfigset('OML_OUTPUT_SZLIMIT', '8000')