-
Notifications
You must be signed in to change notification settings - Fork 2
/
aws-getModel
executable file
·48 lines (40 loc) · 1.27 KB
/
aws-getModel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: $0 <Model Name> <Directory Destination>"
echo "<Model Name> is mandatory"
echo "<Directory Destination> is optional"
exit 1
fi
if [ -z $2 ]; then
DESTDIR="."
else
DESTDIR="$2"
fi
MODELNAME=$1
CONFIGFILE="aws-deepracer.cf"
if [ -f $CONFIGFILE ]; then
ACCOUNTID=$(grep -i ACCOUNTID $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}')
else
echo "The config file $CONFIGFILE is not found"
exit 1
fi
DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.GetModel"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"ModelArn\":\"arn:aws:deepracer:us-east-1:'
DATA+=$ACCOUNTID
DATA+=':model/reinforcement_learning/'
DATA+=$MODELNAME
DATA+='\"}","operation":"getModel"}'
export DATA
./aws-execCurl > .curl.result
errorMessage=$(jq '.error[0]' .curl.result)
if [ "$errorMessage" != 'null' ]; then
echo "$errorMessage"
exit 1
fi
DRMODEL=$(jq '.Model.ModelArtifactS3Location' .curl.result | awk '{gsub("\"", "", $1); print $1}')
rm -f .curl.result
if [ $DRMODEL != 'null' ]; then
aws s3 cp "$DRMODEL" "$DESTDIR"
else
echo "$MODELNAME is not found"
exit 1
fi