Skip tests if C2/ONNX models cannot be read (#18494)
authorMin Ni <minn@fb.com>
Wed, 27 Mar 2019 18:14:32 +0000 (11:14 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 27 Mar 2019 18:21:44 +0000 (11:21 -0700)
commitc3e3c5cc39165470ddab5afb6373399fdbd6598e
tree26ab77d06c2d40c721080f5d6bb1274dd0dd044f
parent30da6c7d0697fa1ae315174fcf01b3d16abb18c6
Skip tests if C2/ONNX models cannot be read (#18494)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18494

Today we have some C2 end2end test run requiring reading model data from external filesystem (for example, Gluster and AWS). This could be a source for flaky test when the external filesystems are not reachable during the tests.

In this diff, we add try/catch logic around where we download models and open model files from external system. In case such attempts fails, we will catch the excption and let the unittest skip the current test instead of failure.

I also refactor the code a little bit by removing some duplicated logic on downloading and build the c2 model data. It has been duplicated in two classes and a few functions...

Reviewed By: yinghai

Differential Revision: D14442241

fbshipit-source-id: da8bf56c8d096efa34ca2070de5cd10a18aad70c
caffe2/python/models/download.py
caffe2/python/onnx/test_onnxifi.py
caffe2/python/onnx/tests/c2_ref_test.py
caffe2/python/onnx/tests/test_utils.py
caffe2/python/trt/test_trt.py