10
10
# print instructions for committing the build container, tagging and pushing to dockerhub
11
11
# ###
12
12
13
+ # set the tag container
14
+ GRIDAPPSD_TAG=' :develop'
15
+
16
+
17
+ export PYTHONWARNINGS=" ignore"
18
+
13
19
usage () {
14
20
/bin/echo " Usage: $0 [-d]"
15
21
/bin/echo " -d debug"
@@ -55,14 +61,42 @@ http_status_container() {
55
61
fi
56
62
}
57
63
64
+ build_dir=bzbuild/build_$( date +" %Y%m%d%H%M%S" )
65
+
66
+ if [ -d $build_dir ]; then
67
+ echo " $build_dir exists"
68
+ echo " Exiting..."
69
+ exit 1
70
+ fi
71
+
72
+ echo " Build directory: $build_dir "
73
+ mkdir -p $build_dir
74
+ cp $0 $build_dir
75
+ cp Dockerfile.gridappsd_blazegraph $build_dir
76
+ mkdir ${build_dir} /conf
77
+ cp -rp ./conf/rwstore.properties ${build_dir} /conf
78
+ cd $build_dir
79
+
80
+ echo " Logging to : ${build_dir} /create.log"
81
+
82
+ # Close STDOUT file descriptor
83
+ exec 1< & -
84
+ # Close STDERR FD
85
+ exec 2< & -
86
+
87
+ # Open STDOUT as $LOG_FILE file for read and write.
88
+ exec 1<> create.log
89
+
90
+ # Redirect STDERR to STDOUT
91
+ exec 2>&1
92
+
93
+ date
94
+
58
95
url_viz=" http://localhost:8080/"
59
- blazegraph_models=" ACEP_PSIL.xml EPRI_DPV_J1.xml IEEE123.xml IEEE123_PV.xml IEEE13.xml IEEE13_Assets.xml IEEE8500.xml IEEE8500_3subs.xml R2_12_47_2.xml"
60
- url_blazegraph=" http://localhost:8889/bigdata/"
61
- data_dir=" Powergrid-Models/blazegraph/test"
96
+ url_blazegraph=" http://localhost:8889/bigdata/namespace/kb/"
97
+ data_dir=" Powergrid-Models/platform/cimxml"
62
98
debug=0
63
99
exists=0
64
- # set the default tag for the gridappsd and viz containers
65
- GRIDAPPSD_TAG=' :develop'
66
100
67
101
# parse options
68
102
while getopts dpt: option ; do
@@ -114,7 +148,8 @@ if [ -d Powergrid-Models ]; then
114
148
git pull -v
115
149
cd $cwd
116
150
else
117
- git clone http://github.com/GRIDAPPSD/Powergrid-Models -b develop
151
+ git clone http://github.com/GRIDAPPSD/Powergrid-Models -b gridappsd
152
+ git clone http://github.com/GRIDAPPSD/CIMHub -b gridappsd
118
153
fi
119
154
120
155
GITHASH=` git -C Powergrid-Models log -1 --pretty=format:" %h" `
@@ -123,118 +158,24 @@ http_status_container 'blazegraph'
123
158
124
159
bz_load_status=0
125
160
echo " "
126
- echo " Checking blazegraph data"
161
+ echo " Importing blazegraph data"
127
162
128
- echo " "
129
- # Check if blazegraph data is already loaded
130
- rangeCount=` curl -s -G -H ' Accept: application/xml' " ${url_blazegraph} sparql" --data-urlencode ESTCARD | sed ' s/.*rangeCount=\"\([0-9]*\)\".*/\1/' `
131
- if [ x" $rangeCount " == x" 0" ]; then
132
- for blazegraph_file in $blazegraph_models ; do
133
- echo " Ingesting blazegraph data $data_dir /$blazegraph_file ${url_blazegraph} sparql ($rangeCount )"
134
- debug_msg " curl -s -D- -H 'Content-Type: application/xml' --upload-file \" $data_dir /$blazegraph_file \" -X POST \" ${url_blazegraph} sparql\" "
135
- curl_output=` curl -s -D- -H ' Content-Type: application/xml' --upload-file " $data_dir /$blazegraph_file " -X POST " ${url_blazegraph} sparql" `
136
- debug_msg " curl output: $curl_output "
137
- bz_status=` echo $curl_output | grep -c ' data modified=' `
138
-
139
- if [ ${bz_status:- 0} -ne 1 ]; then
140
- echo " Error could not ingest blazegraph data file $data_dir /$blazegraph_file "
141
- echo $curl_output
142
- bz_load_status=1
143
- fi
144
- # echo "Verifying blazegraph data"
145
- rangeCount=` curl -s -G -H ' Accept: application/xml' " ${url_blazegraph} sparql" --data-urlencode ESTCARD | sed ' s/.*rangeCount=\"\([0-9]*\)\".*/\1/' `
146
- done
147
-
148
- if [ ${rangeCount:- 0} -gt 0 -a $bz_load_status == 0 ]; then
149
- echo " Finished ingesting blazegraph data files ($rangeCount )"
150
- else
151
- echo " Error ingesting blazegraph data files ($rangeCount )"
152
- echo " Exiting "
153
- echo " "
154
- # echo $curl_output
155
- exit 1
156
- fi
157
- else
158
- echo " Error Blazegrpah already contains data ($rangeCount )"
159
- exit 1
163
+ cd Powergrid-Models/platform
164
+ if [ ! -f envars.sh ]; then
165
+ cp envars_docker.sh envars.sh
160
166
fi
161
-
162
- echo " "
163
- echo " docker commit $did gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} _models "
164
- docker commit $did gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} _models
165
- echo " "
166
-
167
- # load the measurements
168
- echo " "
169
- echo " Loading the measurements"
170
-
171
- echo " "
172
- echo " Modifying the Powergrid-Models/Meas/constants.py file for loading data into local docker container"
173
- sed -i' .bak' -e ' s/^blazegraph_url.*$/blazegraph_url = \"http:\/\/localhost:8889\/bigdata\/sparql\"/' Powergrid-Models/Meas/constants.py
174
-
175
- cd Powergrid-Models/Meas
176
- if [ ! -d tmp ]; then
177
- mkdir tmp
178
- else
179
- rm tmp/* txt 2> /dev/null
167
+ if [ ! -f cimhubconfig.json ]; then
168
+ cp cimhubdocker.json cimhubconfig.json
180
169
fi
181
- cd tmp
182
-
183
- echo " "
184
- echo " Generating measurements files"
185
- python3 ../ListFeeders.py | grep -v ' binding keys' | while read line; do
186
- echo " Generating measurements files for $line "
187
- python3 ../ListMeasureables.py $line
188
- done
189
-
190
- echo " "
191
- echo " Measurements found"
192
- # shasum * | shasum | cut -d' ' -f1
193
- wc -l * txt | grep total | awk ' {print $1}'
194
170
195
- echo " "
196
- echo " Loading measurements files"
197
- ls -1 * txt | xargs -P 12 -n 1 -I, bash -c ' echo " Loading measurments file ,";python3 ../InsertMeasurements.py ,'
198
-
199
- echo " "
200
- rangeCount=` curl -s -G -H ' Accept: application/xml' " ${url_blazegraph} sparql" --data-urlencode ESTCARD | sed ' s/.*rangeCount=\"\([0-9]*\)\".*/\1/' `
201
- echo " Finished loading blazegraph measurements ($rangeCount )"
202
- echo " "
203
- echo " docker commit $did gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} _measurements "
204
- docker commit $did gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} _measurements
205
-
206
- cd ../../houses
207
- # assign random climate zones (1-5) to lookup
208
- zone_acep_psil=1
209
- zone_ieee123=2
210
- zone_ieee123pv=3
211
- zone_ieee13nodeckt=4
212
- zone_ieee13nodecktassets=5
213
- zone_ieee8500=3
214
- zone_ieee8500new_335=4
215
- zone_j1=1
216
- zone_sourceckt=2
217
-
218
- echo " "
219
- echo " Loading houses"
220
- python3 ../Meas/ListFeeders.py | grep -v ' binding keys' | while read fdrname fdrid ; do
221
- # use lookup
222
- climate_zone=" zone_$fdrname "
223
- echo " Loading houses for $fdrname : $fdrid : ${! climate_zone} "
224
- python3 insertHouses.py $fdrid ${! climate_zone}
225
- status=$?
226
- if [ $status -gt 0 ]; then
227
- echo " "
228
- echo " Failed loading houses for $fdrname : python3 insertHouses.py $fdrid ${! climate_zone} "
229
- echo " "
230
- fi
231
- done
171
+ ./import_all.sh
172
+ status=$?
173
+ echo " status: $status "
232
174
233
175
echo " "
234
176
rangeCount=` curl -s -G -H ' Accept: application/xml' " ${url_blazegraph} sparql" --data-urlencode ESTCARD | sed ' s/.*rangeCount=\"\([0-9]*\)\".*/\1/' `
235
177
echo " Finished loading blazegraph houses ($rangeCount )"
236
178
237
-
238
179
echo " "
239
180
echo " ----"
240
181
echo " docker commit $did gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} "
@@ -244,7 +185,7 @@ docker stop $did
244
185
echo " "
245
186
echo " Run these commands to commit the container and push the container to dockerhub"
246
187
echo " ----"
247
- echo " docker tag gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} gridappsd/blazegraph:develop "
188
+ echo " docker tag gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} gridappsd/blazegraph${GRIDAPPSD_TAG} "
248
189
echo " docker push gridappsd/blazegraph:${TIMESTAMP} _${GITHASH} "
249
190
echo " docker push gridappsd/blazegraph:develop"
250
191
0 commit comments