@@ -52,7 +52,7 @@ def main():
5252
5353 # Component versions
5454 tf_version = "v2.5.1"
55- ovtf_version = "v1.0.0 "
55+ ovtf_version = "v1.0.1 "
5656 use_intel_tf = False
5757
5858 # Command line parser options
@@ -163,10 +163,11 @@ def main():
163163 arguments = parser .parse_args ()
164164
165165 if arguments .cxx11_abi_version == "1" and not arguments .build_tf_from_source :
166- assert (tf_version == arguments .tf_version ), (
167- "Currently ABI1 Tensorflow %s wheel is unavailable. " %
168- arguments .tf_version +
169- "Please consider adding --build_tf_from_source" )
166+ if not (tf_version == arguments .tf_version ):
167+ raise AssertionError (
168+ "Currently ABI1 Tensorflow %s wheel is unavailable. " %
169+ arguments .tf_version +
170+ "Please consider adding --build_tf_from_source" )
170171
171172 # Update the build time tensorflow version with the user specified version
172173 tf_version = arguments .tf_version
@@ -186,55 +187,65 @@ def main():
186187 # Default directories
187188 build_dir = arguments .build_dir
188189
189- assert not (
190- arguments . use_tensorflow_from_location != '' and
191- arguments . build_tf_from_source ), (
190+ if ( arguments . use_tensorflow_from_location != '' and
191+ arguments . build_tf_from_source ):
192+ raise AssertionError (
192193 "\" use_tensorflow_from_location\" and \" build_tf_from_source\" "
193194 "cannot be used together." )
194-
195- assert not ( arguments . openvino_version not in [
196- "2021.4.1" , "2021.4" , "2021.3" , "2021.2"
197- ]), (
198- "Only 2021.2, 2021.3, 2021.4 and 2021.4.1 OpenVINO versions are supported"
199- )
195+ if ( arguments . openvino_version not in [
196+ "2021.4.1" , "2021.4" , "2021.3" , "2021.2"
197+ ]):
198+ raise AssertionError (
199+ "Only 2021.2, 2021.3, 2021.4 and 2021.4.1 OpenVINO versions are supported"
200+ )
200201
201202 if arguments .use_openvino_from_location != '' :
203+ if not os .path .isdir (arguments .use_openvino_from_location ):
204+ raise AssertionError ("Path doesn't exist {0}" .format (
205+ arguments .use_openvino_from_location ))
202206 ver_file = arguments .use_openvino_from_location + \
203207 '/deployment_tools/inference_engine/version.txt'
204- assert os .path .exists (ver_file ), "Path doesn't exist {0}" . format (
205- ver_file )
208+ if not os .path .exists (ver_file ):
209+ raise AssertionError ( "Path doesn't exist {0}" . format ( ver_file ) )
206210 with open (ver_file ) as f :
207211 line = f .readline ()
208- assert line .find (arguments .openvino_version ) != - 1 , "OpenVINO version " + \
209- arguments .openvino_version + \
210- " does not match the version specified in use_openvino_from_location"
212+ if not line .find (arguments .openvino_version ) != - 1 :
213+ raise AssertionError ("OpenVINO version " + \
214+ arguments .openvino_version + \
215+ " does not match the version specified in use_openvino_from_location" )
211216
212217 version_check ((not arguments .build_tf_from_source ),
213218 (arguments .use_tensorflow_from_location != '' ),
214219 arguments .disable_cpp_api )
215220
216221 if arguments .use_tensorflow_from_location != '' :
217222 # Check if the prebuilt folder has necessary files
218- assert os .path .isdir (
219- arguments .use_tensorflow_from_location
220- ), "Prebuilt TF path " + arguments .use_tensorflow_from_location + " does not exist"
223+ if not os .path .isdir (arguments .use_tensorflow_from_location ):
224+ raise AssertionError ("Prebuilt TF path " +
225+ arguments .use_tensorflow_from_location +
226+ " does not exist" )
221227 loc = arguments .use_tensorflow_from_location + '/artifacts/tensorflow'
222- assert os .path .isdir (
223- loc ), "Could not find artifacts/tensorflow directory"
228+ if not os .path .isdir (loc ):
229+ raise AssertionError (
230+ "Could not find artifacts/tensorflow directory" )
224231 found_whl = False
225232 found_libtf_fw = False
226233 found_libtf_cc = False
227- assert os .path .exists (loc ), "Path doesn't exist {0}" .format (loc )
234+ if not os .path .exists (loc ):
235+ raise AssertionError ("Path doesn't exist {0}" .format (loc ))
228236 for i in os .listdir (loc ):
229237 if '.whl' in i :
230238 found_whl = True
231239 if 'libtensorflow_cc' in i :
232240 found_libtf_cc = True
233241 if 'libtensorflow_framework' in i :
234242 found_libtf_fw = True
235- assert found_whl , "Did not find TF whl file"
236- assert found_libtf_fw , "Did not find libtensorflow_framework"
237- assert found_libtf_cc , "Did not find libtensorflow_cc"
243+ if not found_whl :
244+ raise AssertionError ("Did not find TF whl file" )
245+ if not found_libtf_fw :
246+ raise AssertionError ("Did not find libtensorflow_framework" )
247+ if not found_libtf_cc :
248+ raise AssertionError ("Did not find libtensorflow_cc" )
238249
239250 try :
240251 os .makedirs (build_dir )
@@ -246,8 +257,8 @@ def main():
246257 openvino_tf_src_dir = os .path .abspath (pwd )
247258 print ("OVTF SRC DIR: " + openvino_tf_src_dir )
248259 build_dir_abs = os .path .abspath (build_dir )
249- assert os .path .exists (build_dir_abs ), "Directory doesn't exist {}" . format (
250- build_dir_abs )
260+ if not os .path .exists (build_dir_abs ):
261+ raise AssertionError ( "Directory doesn't exist {}" . format ( build_dir_abs ) )
251262 os .chdir (build_dir )
252263
253264 venv_dir = 'venv-tf-py3'
@@ -256,12 +267,13 @@ def main():
256267 artifacts_location = os .path .abspath (arguments .artifacts_dir )
257268
258269 artifacts_location = os .path .abspath (artifacts_location )
259- print ("ARTIFACTS location: " + artifacts_location )
260270
261271 #If artifacts doesn't exist create
262272 if not os .path .isdir (artifacts_location ):
263273 os .mkdir (artifacts_location )
264274
275+ print ("ARTIFACTS location: " + artifacts_location )
276+
265277 #install virtualenv
266278 install_virtual_env (venv_dir )
267279
@@ -275,8 +287,6 @@ def main():
275287 if (arguments .target_arch ):
276288 target_arch = arguments .target_arch
277289
278- print ("Target Arch: %s" % target_arch )
279-
280290 # The cxx_abi flag is translated to _GLIBCXX_USE_CXX11_ABI
281291 # For gcc older than 5.3, this flag is set to 0 and for newer ones,
282292 # this is set to 1
@@ -293,26 +303,28 @@ def main():
293303 # The tf whl should be in use_tensorflow_from_location/artifacts/tensorflow
294304 tf_whl_loc = os .path .abspath (arguments .use_tensorflow_from_location +
295305 '/artifacts/tensorflow' )
296- assert os .path .exists (tf_whl_loc ), "path doesn't exist {0}" . format (
297- tf_whl_loc )
306+ if not os .path .exists (tf_whl_loc ):
307+ raise AssertionError ( "path doesn't exist {0}" . format ( tf_whl_loc ) )
298308 possible_whl = [i for i in os .listdir (tf_whl_loc ) if '.whl' in i ]
299- assert len (
300- possible_whl
301- ) == 1 , "Expected one TF whl file, but found " + len (possible_whl )
309+ if not len (possible_whl ) == 1 :
310+ raise AssertionError ( "Expected one TF whl file, but found " +
311+ len (possible_whl ) )
302312 # Make sure there is exactly 1 TF whl
303313 tf_whl = os .path .abspath (tf_whl_loc + '/' + possible_whl [0 ])
304- assert os .path .isfile (tf_whl ), "Did not find " + tf_whl
314+ if not os .path .isfile (tf_whl ):
315+ raise AssertionError ("Did not find " + tf_whl )
305316 # Install the found TF whl file
306317 command_executor (["pip" , "install" , "--force-reinstall" , "-U" , tf_whl ])
307318 tf_cxx_abi = get_tf_cxxabi ()
308319
309- assert (arguments .cxx11_abi_version == tf_cxx_abi ), (
310- "Desired ABI version and user built tensorflow library provided with "
311- "use_tensorflow_from_location are incompatible" )
320+ if not (arguments .cxx11_abi_version == tf_cxx_abi ):
321+ raise AssertionError (
322+ "Desired ABI version and user built tensorflow library provided with "
323+ "use_tensorflow_from_location are incompatible" )
312324
313325 cwd = os .getcwd ()
314- assert os .path .exists (tf_whl_loc ), "Path doesn't exist {0}" . format (
315- tf_whl_loc )
326+ if not os .path .exists (tf_whl_loc ):
327+ raise AssertionError ( "Path doesn't exist {0}" . format ( tf_whl_loc ) )
316328 os .chdir (tf_whl_loc )
317329 tf_in_artifacts = os .path .join (
318330 os .path .abspath (artifacts_location ), "tensorflow" )
@@ -324,11 +336,11 @@ def main():
324336 tf_version = get_tf_version ()
325337 copy_tf_to_artifacts (tf_version , tf_in_artifacts , tf_whl_loc ,
326338 use_intel_tf )
327- assert os .path .exists (cwd ), "Path doesn't exist {0}" .format (cwd )
339+ if not os .path .exists (cwd ):
340+ raise AssertionError ("Path doesn't exist {0}" .format (cwd ))
328341 os .chdir (cwd )
329342 else :
330343 if not arguments .build_tf_from_source :
331- print ("Using TensorFlow version" , tf_version )
332344 print ("Install TensorFlow" )
333345
334346 if arguments .cxx11_abi_version == "0" :
@@ -342,43 +354,49 @@ def main():
342354 if tags .interpreter == "cp36" :
343355 command_executor ([
344356 "pip" , "install" , "--force-reinstall" ,
345- "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.0 /tensorflow_abi1-2.5.1-cp36-cp36m-manylinux2010_x86_64.whl"
357+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.1 /tensorflow_abi1-2.5.1-cp36-cp36m-manylinux2010_x86_64.whl"
346358 ])
347359 if tags .interpreter == "cp37" :
348360 command_executor ([
349361 "pip" , "install" , "--force-reinstall" ,
350- "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.0 /tensorflow_abi1-2.5.1-cp37-cp37m-manylinux2010_x86_64.whl"
362+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.1 /tensorflow_abi1-2.5.1-cp37-cp37m-manylinux2010_x86_64.whl"
351363 ])
352364 if tags .interpreter == "cp38" :
353365 command_executor ([
354366 "pip" , "install" , "--force-reinstall" ,
355- "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.0/tensorflow_abi1-2.5.1-cp38-cp38-manylinux2010_x86_64.whl"
367+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.1/tensorflow_abi1-2.5.1-cp38-cp38-manylinux2010_x86_64.whl"
368+ ])
369+ if tags .interpreter == "cp39" :
370+ command_executor ([
371+ "pip" , "install" , "--force-reinstall" ,
372+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v1.0.1/tensorflow_abi1-2.5.1-cp39-cp39-manylinux2010_x86_64.whl"
356373 ])
357-
358374 # ABI 1 TF required latest numpy
359375 command_executor (
360376 ["pip" , "install" , "--force-reinstall" , "-U numpy" ])
361377
362378 tf_cxx_abi = get_tf_cxxabi ()
363379
364- assert (arguments .cxx11_abi_version == tf_cxx_abi ), (
365- "Desired ABI version and tensorflow library installed with "
366- "pip are incompatible" )
380+ if not (arguments .cxx11_abi_version == tf_cxx_abi ):
381+ raise AssertionError (
382+ "Desired ABI version and tensorflow library installed with "
383+ "pip are incompatible" )
367384
368385 tf_src_dir = os .path .join (artifacts_location , "tensorflow" )
369386 print ("TF_SRC_DIR: " , tf_src_dir )
370387 # Download TF source for enabling TF python tests
371388 pwd_now = os .getcwd ()
372- assert os .path .exists (
373- artifacts_location ), "Path doesn't exist {0}" . format (
374- artifacts_location )
389+ if not os .path .exists (artifacts_location ):
390+ raise AssertionError (
391+ "Path doesn't exist {0}" . format ( artifacts_location ) )
375392 os .chdir (artifacts_location )
376393 print ("DOWNLOADING TF: PWD" , os .getcwd ())
377394 download_repo ("tensorflow" ,
378395 "https://github.com/tensorflow/tensorflow.git" ,
379396 tf_version )
380- assert os .path .exists (pwd_now ), "Path doesn't exist {0}" .format (
381- pwd_now )
397+ print ("Using TensorFlow version" , tf_version )
398+ if not os .path .exists (pwd_now ):
399+ raise AssertionError ("Path doesn't exist {0}" .format (pwd_now ))
382400 os .chdir (pwd_now )
383401 # Finally, copy the libtensorflow_framework.so to the artifacts
384402 if (tf_version .startswith ("v1." ) or (tf_version .startswith ("1." ))):
@@ -396,8 +414,9 @@ def main():
396414 tf_lib_file = os .path .join (tf_lib_dir , tf_fmwk_lib_name )
397415 print ("SYSCFG LIB: " , tf_lib_file )
398416 dst_dir = os .path .join (artifacts_location , "tensorflow" )
399- assert os .path .exists (
400- dst_dir ), "Directory doesn't exist {0}" .format (dst_dir )
417+ if not os .path .exists (dst_dir ):
418+ raise AssertionError (
419+ "Directory doesn't exist {0}" .format (dst_dir ))
401420 if not os .path .isdir (dst_dir ):
402421 os .mkdir (dst_dir )
403422 dst = os .path .join (dst_dir , tf_fmwk_lib_name )
@@ -532,11 +551,11 @@ def main():
532551 openvino_tf_cmake_flags , verbosity )
533552
534553 # Make sure that the openvino_tensorflow whl is present in the artfacts directory
535- assert os .path .exists (artifacts_location ), "Path not found {}" . format (
536- artifacts_location )
537- assert os .path .isfile (os .path .join (
538- artifacts_location ,
539- ov_tf_whl )), "Cannot locate nGraph whl in the artifacts location"
554+ if not os .path .exists (artifacts_location ):
555+ raise AssertionError ( "Path not found {}" . format ( artifacts_location ) )
556+ if not os .path .isfile (os .path .join (artifacts_location , ov_tf_whl )):
557+ raise AssertionError (
558+ "Cannot locate nGraph whl in the artifacts location" )
540559 if not os .path .isfile (os .path .join (artifacts_location , ov_tf_whl )):
541560 raise Exception ("Cannot locate nGraph whl in the artifacts location" )
542561
@@ -578,8 +597,8 @@ def main():
578597 command_executor (['ln' , '-sf' , link_src , link_dst ], verbose = True )
579598
580599 # Run a quick test
581- assert os .path .exists (artifacts_location ), "Path doesn't exist {}" . format (
582- artifacts_location )
600+ if not os .path .exists (artifacts_location ):
601+ raise AssertionError ( "Path doesn't exist {}" . format ( artifacts_location ) )
583602 install_openvino_tf (tf_version , venv_dir ,
584603 os .path .join (artifacts_location , ov_tf_whl ))
585604
0 commit comments