LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

[RescaleAPI] 計算結果の中からダウンロードしたいファイルの fileId を調べる (計算完了後)

Last updated at Posted at 2017-02-13

0. 前提

事前に下記が実施されていることを前提とします。設定済みであれば飛ばしてOKです。

1. 計算結果の中からダウンロードしたいファイルの fileId を調べる (計算完了後)

上記モニタリングで, "comleted" が表示されている必要があいます

1.1 スクリプトの作成

以下のシェルスクリプトを "rescale-jobFileList.sh" という名前で保存します。

rescale-download.shの作成
vi ${script}/rescale-jobFileList.sh
source
#!/bin/sh

jobId=$1
runId=1
TOKEN="${RESCALE_API_TOKEN}"

i=0
while :
do
    let "pageId=i+1"
    url="https://platform.rescale.jp/api/v2/jobs/${jobId}/runs/${runId}/files/?page=${pageId}"
    myJson[i]=$(curl -s -X GET -H "Authorization: Token ${TOKEN}" ${url})
    nextPage=$(echo "${myJson[i]}" | jq .next)
    let "i++"

    if [ "${nextPage}" = "null" ]; then
        break
    fi
done

imax=$i
for((i=0;i<${imax};i++))
do
    echo ${myJson[i]}| jq -r '.results[] | "\(.id)\t\(.name)"'
done
実行権限付与
chmod +x ${script}/rescale-jobFileList.sh

1.2 実行例

以下の方法で実行します。ここでは、"process_output.log"という計算時の標準出力の内容が記録されているファイルのfileIdを取得します

実行方法
targetFile="process_output.log"
downloadFileId=$(rescale-jobFileList.sh ${jobId} \
| grep ${targetFile} \
| awk '{print $1}') \
&& echo ${downloadFileId}

実行結果は以下で左の列がfileIdになります。これを

結果例
Pkvjd
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up