comparison MLaaS/demo.sh @ 0:cbbe42422d56 draft

planemo upload for repository https://github.com/CHESSComputing/ChessAnalysisPipeline/tree/galaxy commit 1401a7e1ae007a6bda260d147f9b879e789b73e0-dirty
author kls286
date Tue, 28 Mar 2023 15:07:30 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cbbe42422d56
1 #!/bin/bash
2 # TFaaS host name
3 turl=http://localhost:8083
4 # location of files
5 tdir=/home/vk/chess/TFaaS/models
6 # we need the following files
7 model_tarball=$tdir/model.tar.gz
8 params_json=$tdir/vk/params.json
9 input_json=$tdir/vk/input.json
10 upload_json=$tdir/vk/upload.json
11 model_pb=$tdir/vk/model.pb
12 labels_txt=$tdir/vk/labels.txt
13 tfaas_client=$tdir/tfaas_client.py
14 hey=$tdir/hey-tools/hey_amd64
15
16 echo "### obtain any existing ML model"
17 echo
18 echo "$tfaas_client --url=$turl --models"
19 echo
20 $tfaas_client --url=$turl --models
21 sleep 1
22 echo
23
24 echo "### upload new ML model"
25 echo
26 echo "cat $upload_json"
27 echo
28 cat $upload_json
29 echo
30 echo "$tfaas_client --url=$turl --upload=$upload_json"
31 $tfaas_client --url=$turl --upload=$upload_json
32 echo
33
34 echo "### view if our model exists"
35 echo
36 echo "$tfaas_client --url=$turl --models"
37 echo
38 $tfaas_client --url=$turl --models
39 sleep 2
40 echo
41
42 echo "### view if our model exists, but use jq tool to get better view over JSON"
43 echo
44 echo "$tfaas_client --url=$turl --models | jq"
45 echo
46 $tfaas_client --url=$turl --models | jq
47 sleep 2
48 echo
49
50 echo "### let's obtain some prediction"
51 echo
52 echo "cat $input_json"
53 echo
54 cat $input_json
55 echo
56 echo "$tfaas_client --url=$turl --predict=$input_json"
57 echo
58 $tfaas_client --url=$turl --predict=$input_json
59 sleep 2
60 echo
61
62 echo "### let's delete our ML model named vk"
63 echo
64 echo "$tfaas_client --url=$turl --delete=vk"
65 echo
66 $tfaas_client --url=$turl --delete=vk
67 sleep 1
68 echo
69
70 echo "### lets view again available models"
71 echo
72 echo "$tfaas_client --url=$turl --models"
73 echo
74 $tfaas_client --url=$turl --models
75 sleep 2
76 echo
77
78 echo "### now let's use curl as CLI tool to communicate with TFaaS"
79 echo
80 sleep 5
81
82 echo "### Let's view our models"
83 echo
84 echo "curl -s $turl/models"
85 echo
86 curl -s $turl/models
87 sleep 1
88 echo
89
90 echo "### let's send POST HTTP request with our parameters to upload ML model"
91 echo "### we provide $params_json"
92 echo
93 cat $params_json
94 echo
95 echo "### we provide $model_pb TF model"
96 echo
97 ls -al $model_pb
98 echo
99 echo "### and we provide our labels in $labels_txt file"
100 echo
101 cat $labels_txt
102 echo
103 echo "### now we make curl call"
104 echo
105 echo "curl -s -X POST $turl/upload -F 'name=vk' -F 'params=@$params_json' -F 'model=@$model_pb' -F 'labels=@$labels_txt'"
106 echo
107 curl -s -X POST $turl/upload -F 'name=vk' -F "params=@$params_json" -F "model=@$model_pb" -F "labels=@$labels_txt"
108 sleep 1
109 echo
110
111 echo "### Now we can view our models"
112 echo
113 echo "curl -s $turl/models | jq"
114 echo
115 curl -s $turl/models | jq
116 echo
117 sleep 2
118
119 echo "### And we can obtain our predictions using /json API"
120 echo
121 echo "curl -s -X POST $turl/json -H "Content-type: application/json" -d@$input_json"
122 echo
123 curl -s -X POST $turl/json -H "Content-type: application/json" -d@$input_json
124 sleep 1
125 echo
126
127 echo "### Now we can delete ML model using /delete end-point"
128 echo
129 echo "curl -s -X DELETE $turl/delete -F 'model=vk'"
130 echo
131 curl -s -X DELETE $turl/delete -F 'model=vk'
132 sleep 1
133 echo
134
135 echo "### Now we can view our models"
136 echo
137 echo "curl -s $turl/models"
138 echo
139 curl -s $turl/models
140 echo
141 sleep 1
142
143 $tfaas_client --url=$turl --upload=$upload_json
144
145 echo
146 echo "### now let's use tar ball and upload it"
147 echo
148 ls -al $model_tarball
149 tar tvfz $model_tarball
150 sleep 5
151
152 echo "curl -v -X POST -H \"Content-Encoding: gzip\" -H \"content-type: application/octet-stream\" --data-binary @$model_tarball $turl/upload"
153 curl -v -X POST -H"Content-Encoding: gzip" -H"content-type: application/octet-stream" --data-binary @$model_tarball $turl/upload
154 sleep 1
155 echo
156
157 echo "### Now we can view our models"
158 echo
159 echo "curl -s $turl/models | jq"
160 echo
161 curl -s $turl/models | jq
162 echo
163 sleep 2
164
165 echo "### And we can obtain our predictions using /json API"
166 echo
167 echo "curl -s -X POST $turl/json -H "Content-type: application/json" -d@$input_json"
168 echo
169 curl -s -X POST $turl/json -H "Content-type: application/json" -d@$input_json
170 sleep 1
171 echo
172
173 if [ -f $hey ]; then
174 echo "### Now let's perform some stress tests"
175 echo "### for that we'll use hey tool which will send number of concurrent requests to tfaas service"
176 echo
177 echo "$hey -m POST -H "Content-type: application/json" -D $input_json $turl/json"
178 $hey -m POST -H "Content-type: application/json" -D $input_json $turl/json
179 fi