指定したデータに対するPython関数の実行
post
/py-scripts/v1/table-apply/{scriptName}
指定されたデータに対してユーザー所有のPython関数を実行します。
リクエスト
パス・パラメータ
- scriptName(必須):
Pythonスクリプトの名前
レスポンス
200レスポンス
デフォルトでは、ジョブの結果を返します。
201レスポンス
400レスポンス
無効なパラメータが指定され、出力がサイズ制限を超えているか、他のスクリプト実行エラーが発生しました。
500レスポンス
ブローカへの接続中、ジョブの実行中に問題が発生したか、または他の予期しないエラーが発生しました。
例
例1
次の例では、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"
レスポンス・ヘッダー
レスポンス・ヘッダーは次のとおりです。
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
レスポンス本文
JSON形式のレスポンス本文の一部を次に示します。
{"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},...]}
例2
次の例では、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"
レスポンス本文
RESTエンドポイントの結果は、イメージおよびデータを含むPythonスクリプトから返される値のJSON表現です。イメージ・バイトはPNG形式で返されます。
{
"result": [
{
"IMAGE": "iVBORw0KGgoAAAAN......7xR5qN5koAAAAASUVORK5CYII=",
"DATA": "\"hello world\"",
"TITLE": "Iris plot",
"ID": 1
}
]
}