Run a Python Function multiple times with Script Owner Specified
post
/api/py-scripts/v1/index-apply/{scriptName}/{ownerName}
Run a Python Function "times" times with script owner specified.
Request
Supported Media Types
- application/json
Path Parameters
-
ownerName: string
The owner of the Python script
-
scriptName: string
The name of the Python script
A JSON str of (name - value) pairs specifying arguments of the request and additional arguments to the script
Root Schema : EmbedScriptComputeIdx
Type:
Show Source
object
-
asyncFlag(optional):
boolean
Whether to execute the job asynchronously.
-
envName(optional):
string
Name of the conda environment.
-
graphicsFlag(optional):
boolean
Whether to capture images rendered in the script to the result.
-
parallel(optional):
integer(int32)
Degree of parallelism.
-
parallelFlag(optional):
boolean
Whether to execute job in parallel.
-
parameters(optional):
string
A JSON str of (name - value) pairs specifying keyword arguments to be passed into the script.
-
service(optional):
string
Allowed Values:
[ "LOW", "MEDIUM", "HIGH" ]
LEVEL of the service. Default is LOW. -
timeout(optional):
integer(int32)
Minimum Value:
1800
Maximum Value:43200
The timeout limit (in seconds, default 1800s) of asynchronous job. Must be used together with `asyncFlag`=true. -
times:
integer(int32)
Number of times to execute the script.
Example Request (application/json)
{"times":3, "parallelFlag":true, "service":"MEDIUM", "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
The following example runs the script named compute_random_mean and specifies the script owner.
curl -i -X POST --header "Authorization: Bearer ${token}" \
--header 'Content-Type: application/json' --header 'Accept: application/json' \
-d '{"times":5}' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v1/index-apply/compute_random_mean/<owner_name>"
Response Headers
The response headers are the following:
HTTP/1.1 200 OK
Date: Wed, 26 Aug 2020 21:11:39 GMT
Content-Type: application/json
Content-Length: 196
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=node0qrthj3nw8xiq37kbop7jk5zi655.node0; Path=/oml; Secure; HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Response Body
The response body in JSON format is the following:
{"result":[7.203244934421581,0.25926231827891333,7.081478226181048,5.4723224917572235,8.707323061773764]}