Skip to content

Commit ec7f29c

Browse files
committed
add common.py in nightly_build
Signed-off-by: hwangdeyu <[email protected]>
1 parent ec8b14c commit ec7f29c

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
import urllib
4+
5+
6+
def check_bloburl_access(url):
7+
try:
8+
response = urllib.request.urlopen(url)
9+
return response.getcode() == 200
10+
except urllib.error.URLError:
11+
return False

tests/keras2onnx_applications/nightly_build/test_transformers.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import numpy as np
1313
import tensorflow as tf
1414
from onnxconverter_common.onnx_ex import get_maximum_opset_supported
15+
from common import check_bloburl_access
1516

1617
sys.path.insert(0, os.path.join(dirname(abspath(__file__)), '../../keras2onnx_tests/'))
1718
from test_utils import run_onnx_runtime
@@ -21,20 +22,12 @@
2122
if os.environ.get('ENABLE_FULL_TRANSFORMER_TEST', '0') != '0':
2223
enable_transformer_test = True
2324

24-
def check_bloburl_access():
25-
url = r'https://lotus.blob.core.windows.net/converter-models/transformer_tokenizer/'
26-
try:
27-
response = urllib.request.urlopen(url)
28-
if response.getcode() != 200:
29-
return False
30-
except urllib.error.URLError:
31-
return False
32-
return True
25+
CONVERTER_TRANSFERMER_PATH = r'https://lotus.blob.core.windows.net/converter-models/transformer_tokenizer/'
3326

3427

3528
@unittest.skipIf(is_tensorflow_older_than('2.1.0'),
3629
"Transformers conversion need tensorflow 2.1.0+")
37-
@unittest.skipIf(check_bloburl_access(), "Model blob url can't access")
30+
@unittest.skipIf(check_bloburl_access(CONVERTER_TRANSFERMER_PATH), "Model blob url can't access.")
3831
class TestTransformers(unittest.TestCase):
3932

4033
text_str = 'The quick brown fox jumps over lazy dog.'

tests/keras2onnx_applications/nightly_build/test_yolov3.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from os.path import dirname, abspath
1010
sys.path.insert(0, os.path.join(dirname(abspath(__file__)), '../../keras2onnx_tests/'))
1111
from keras.models import load_model
12+
from common import check_bloburl_access
1213

1314
import urllib.request
1415
YOLOV3_WEIGHTS_PATH = r'https://lotus.blob.core.windows.net/converter-models/yolov3.h5'
@@ -25,16 +26,6 @@
2526
tmp_path = os.path.join(working_path, 'temp')
2627

2728

28-
def check_bloburl_access(url):
29-
try:
30-
response = urllib.request.urlopen(url)
31-
if response.getcode() != 200:
32-
return False
33-
except urllib.error.URLError:
34-
return False
35-
return True
36-
37-
3829
class TestYoloV3(unittest.TestCase):
3930

4031
def setUp(self):
@@ -56,7 +47,7 @@ def post_compute(self, all_boxes, all_scores, indices):
5647
@unittest.skipIf(StrictVersion(onnx.__version__.split('-')[0]) < StrictVersion("1.5.0"),
5748
"NonMaxSuppression op is not supported for onnx < 1.5.0.")
5849
@unittest.skipIf(check_bloburl_access(YOLOV3_WEIGHTS_PATH) or check_bloburl_access(YOLOV3_TINY_WEIGHTS_PATH),
59-
"Model blob url can't access")
50+
"Model blob url can't access.")
6051
def test_yolov3(self):
6152
img_path = os.path.join(os.path.dirname(__file__), '../data', 'street.jpg')
6253
yolo3_yolo3_dir = os.path.join(os.path.dirname(__file__), '../../../keras-yolo3/yolo3')

0 commit comments

Comments
 (0)