Run a Python Function on Specified Data
post
                    /py-scripts/v1/table-apply/{scriptName}
Runs a user-owned Python function on the specified data.
                
                Request
Path Parameters
                - 
                    scriptName(required):  string
                    
                    The name of the Python script
Supported Media Types
                            - application/json
Root Schema : schema
    
    	Type: 
    	
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
        Show Source
        object- 
                
                    
                    asyncFlag: boolean
                    
                    
                     
                    
                
                
                Whether to execute the job asynchronously.
- 
                
                    
                    envName: string
                    
                    
                     
                    
                
                
                Name of the conda environment.
- 
                
                    
                    graphicsFlag: boolean
                    
                    
                     
                    
                
                
                Whether to capture images rendered in the script to the result.
- 
                
                    
                    input(required): string
                    
                    
                     
                    
                
                
                Query statement specifying input data.
- 
                
                    
                    parameters: string
                    
                    
                     
                    
                
                
                A JSON str of (name - value) pairs specifying keyword arguments to be passed into the script.
- 
                
                    
                    service: string
                    
                    
                     
                    
                
                
                Allowed Values:[ "LOW, MEDIUM, HIGH" ]LEVEL of the service. Default is LOW.
- 
                
                    
                    timeout: integer
                    
                    
                     (int32) 
                    
                
                
                Minimum Value:1800Maximum Value:43200The timeout limit (in seconds, default 1800s) of asynchronous job. Must be used together with `asyncFlag`=true.
Response
Supported Media Types
                - application/json
200 Response
By default, returns the job result.
                            
                            
                                201 Response
If asyncFlag=true, returns the location header where the status of the job can be fetched.
                            
                                Headers
                                
                            
                            
                            
                            
                        400 Response
Invalid parameters specified, output exceeding size limit or other script execution error.
                            
                            
                                500 Response
Problem connecting to Broker, executing job or other unexpected error.
                            
                            
                                Examples
Example 1
The following example runs the script named my_predict.
                  
curl -i -X POST --header "Authorization: Bearer ${token}" \
--header 'Content-Type: application/json' --header 'Accept: application/json' \
-d '{"input":"select * from IRIS", "parameters":"{\"oml_input_type\":\"pandas.DataFrame\"}", "parallelFlag":true}' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v1/table-apply/my_predict"Response Headers
The response headers are the following:
HTTP/1.1 200 OK
Date: Thu, 20 Aug 2020 20:03:34 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache, no-store, private
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1;mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=node01x4wuw6qrwa0k11w0p9tf4g71e344.node0; Path=/oml; Secure; HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Response Body
A portion of the response body in JSON format is the following:
{"result":[
{"Pred_Petal_Width":6.8462408185,"Species":"setosa","Petal_Width":0.2},
{"Pred_Petal_Width":5.2786489228,"Species":"versicolor","Petal_Width":1.1},
{"Pred_Petal_Width":5.0951801182,"Species":"versicolor","Petal_Width":1},
{"Pred_Petal_Width":5.24866547,"Species":"versicolor","Petal_Width":1.2},
{"Pred_Petal_Width":4.8406747345,"Species":"versicolor","Petal_Width":1.3},
{"Pred_Petal_Width":4.9825011263,"Species":"versicolor","Petal_Width":1.3},...]}Example 2
The following example runs the script named test_seaborn_inp.
                  
curl -i -k -X POST --header "Authorization: Bearer ${token}" 
--header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"input": "select * from IRIS", "envName": "seaborn", "graphicsFlag": true}' 
"<oml-cloud-service-location-url>/oml/api/py-scripts/v1/table-apply/test_seaborn_inp"Response Body
The result of the REST endpoint is a JSON representation of the value returned from the Python script, which includes the image and the data. Image bytes are returned in PNG format.
{
  "result": [
    {
      "IMAGE": "iVBORw0KGgoAAAAN......7xR5qN5koAAAAASUVORK5CYII=",
      "DATA": "\"hello world\"",
      "TITLE": "Iris plot",
      "ID": 1
    }
  ]
}