R関数の複数回の実行
POST
/api/r-scripts/v1/index-apply/{scriptName}
ユーザー所有のR関数を"times"回実行します。
リクエスト
サポートされているメディア・タイプ
- application/json
パス・パラメータ
- scriptName(必須): string
Rスクリプトの名前。
リクエストの引数とスクリプトの追加引数を指定する(名前 - 値)ペアのJSON文字列
ルート・スキーマ: EmbedScriptComputeIdx
型:
ソースの表示
object
- asyncFlag: boolean
ジョブを非同期で実行するかどうか。
- envName: string
conda環境の名前。
- graphicsFlag: boolean
スクリプトでレンダリングされたイメージを結果に取得するかどうか。
- parallel: integer(int32)
並列度。
- parallelFlag: boolean
ジョブをパラレルに実行するかどうか。
- parameters: string
スクリプトに渡されるキーワード引数を指定する(名前 - 値)ペアのJSON文字列。
- service: string
指定可能な値:
[ "LOW", "MEDIUM", "HIGH" ]
サービスのLEVEL。デフォルトはLOWです。 - timeout: integer(int32)
最小値:
1800
最大値:43200
非同期ジョブのタイムアウト制限(秒単位、デフォルトは1800秒)。`asyncFlag`=trueとともに使用する必要があります。 - times(必須): integer(int32)
スクリプトを実行する回数。
リクエストの例(application/json)
{"times":3, "parallelFlag":true, "graphicsFlag":true, "service":"MEDIUM"}
レスポンス
サポートされているメディア・タイプ
- application/json
200レスポンス
デフォルトでは、ジョブの結果を返します。
201レスポンス
400レスポンス
無効なパラメータが指定され、出力がサイズ制限を超えているか、他のスクリプト実行エラーが発生しました。
500レスポンス
ブローカへの接続中、ジョブの実行中に問題が発生したか、または他の予期しないエラーが発生しました。
例
例1
次の例では、compute.randomMean
というスクリプトを実行します。
curl -i -X POST --header "Authorization: Bearer ${token}" \
--header 'Content-Type: application/json' --header 'Accept: application/json' \
-d '{"times":10, "parallelFlag":true,"service":"MEDIUM"}' \
"<oml-cloud-service-location-url>/oml/api/r-scripts/v1/index-apply/compute.randomMean"
レスポンス・ヘッダー
レスポンス・ヘッダーは次のとおりです。
HTTP/1.1 200 OK
Date: Thu, 28 Jul 2022 21:04:18 GMT
Content-Type: application/json
Content-Length: 1820
Connection: keep-alive
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1;mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Content-Security-Policy: frame-ancestors 'none'
レスポンス本文
JSON形式のレスポンス本文は次のとおりです。
{"result":{"1":0.1322,"2":0.2112,"3":-0.0671,"4":0.5665,"5":-0.0789,"6":0.1054,"7":0.104,"8":-0.4493,"9":-0.219,"10":-0.4907}}
例2
次の例では、test_ggplot2_idx
というスクリプトを実行します。
curl -i -k -X POST --header "Authorization: Bearer ${token}" --header
'Content-Type: application/json' --header 'Accept: application/json' -d
'{"times": 2, "envName": "myrenv", "graphicsFlag": true}'
"<oml-cloudservice-location-url>/oml/api/r-scripts/v1/index-apply/test_ggplot2_idx"
レスポンス本文
RESTエンドポイントの結果は、イメージおよびデータを含むRスクリプトから返される値のJSON表現です。イメージ・バイトはPNG形式で返されます。
{
"result": [
[
{
"IMAGE": "iVBORw0KGgoAAAANSUh......lPb3ruAAAAAElFTkSuQmCC",
"DATA": "\"hello world\"",
"TIME": "1",
"ID": 1
}
],
[
{
"IMAGE": "iVBORw0KGgoAAAANSUh......aOqfnpAAAAAElFTkSuQmCC",
"DATA": "\"hello world\"",
"TIME": "2",
"ID": 1
}
]
]
}