Skip to content

Commit 0223bc9

Browse files
committed
change the function name
Signed-off-by: hwangdeyu <[email protected]>
1 parent 51692cc commit 0223bc9

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

tests/keras2onnx_applications/nightly_build/test_transformers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
import os
4+
from os.path import dirname, abspath
45
import sys
56
import unittest
6-
import mock_keras2onnx
77
import json
88
import urllib.request
99
import pickle
10-
from os.path import dirname, abspath
11-
from mock_keras2onnx.proto import keras
1210
import numpy as np
1311
import tensorflow as tf
12+
1413
from onnxconverter_common.onnx_ex import get_maximum_opset_supported
15-
from test_utils import check_bloburl_access
14+
import mock_keras2onnx
15+
from mock_keras2onnx.proto import keras, is_tensorflow_older_than
16+
from test_utils import is_bloburl_access, run_onnx_runtime
17+
1618

1719
sys.path.insert(0, os.path.join(dirname(abspath(__file__)), '../../keras2onnx_tests/'))
18-
from test_utils import run_onnx_runtime
19-
from mock_keras2onnx.proto import is_tensorflow_older_than
2020

2121
enable_full_transformer_test = False
2222
if os.environ.get('ENABLE_FULL_TRANSFORMER_TEST', '0') != '0':
@@ -27,7 +27,7 @@
2727

2828
@unittest.skipIf(is_tensorflow_older_than('2.1.0'),
2929
"Transformers conversion need tensorflow 2.1.0+")
30-
@unittest.skipIf(check_bloburl_access(CONVERTER_TRANSFERMER_PATH), "Model blob url can't access.")
30+
@unittest.skipIf(not is_bloburl_access(CONVERTER_TRANSFERMER_PATH), "Model blob url can't access.")
3131
class TestTransformers(unittest.TestCase):
3232

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

tests/keras2onnx_applications/nightly_build/test_yolov3.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
import os
4-
import sys
5-
import unittest
6-
import mock_keras2onnx
7-
import onnx
8-
import numpy as np
94
from os.path import dirname, abspath
5+
import numpy as np
6+
import unittest
7+
import sys
108
sys.path.insert(0, os.path.join(dirname(abspath(__file__)), '../../keras2onnx_tests/'))
11-
from keras.models import load_model
12-
from test_utils import check_bloburl_access
9+
sys.path.insert(0, os.path.join(dirname(abspath(__file__)), '../yolov3'))
1310

11+
from keras.models import load_model
12+
import onnx
1413
import urllib.request
14+
from yolov3 import YOLO, convert_model
15+
16+
from distutils.version import StrictVersion
17+
import mock_keras2onnx
18+
from test_utils import is_bloburl_access
19+
20+
1521
YOLOV3_WEIGHTS_PATH = r'https://lotus.blob.core.windows.net/converter-models/yolov3.h5'
1622
model_file_name = 'yolov3.h5'
1723
YOLOV3_TINY_WEIGHTS_PATH = r'https://lotus.blob.core.windows.net/converter-models/yolov3-tiny.h5'
1824
tiny_model_file_name = 'yolov3-tiny.h5'
1925

20-
sys.path.insert(0, os.path.join(dirname(abspath(__file__)), '../yolov3'))
21-
from yolov3 import YOLO, convert_model
22-
23-
from distutils.version import StrictVersion
24-
2526
working_path = os.path.abspath(os.path.dirname(__file__))
2627
tmp_path = os.path.join(working_path, 'temp')
2728

@@ -46,7 +47,7 @@ def post_compute(self, all_boxes, all_scores, indices):
4647

4748
@unittest.skipIf(StrictVersion(onnx.__version__.split('-')[0]) < StrictVersion("1.5.0"),
4849
"NonMaxSuppression op is not supported for onnx < 1.5.0.")
49-
@unittest.skipIf(check_bloburl_access(YOLOV3_WEIGHTS_PATH) or check_bloburl_access(YOLOV3_TINY_WEIGHTS_PATH),
50+
@unittest.skipIf(not is_bloburl_access(YOLOV3_WEIGHTS_PATH) or not is_bloburl_access(YOLOV3_TINY_WEIGHTS_PATH),
5051
"Model blob url can't access.")
5152
def test_yolov3(self):
5253
img_path = os.path.join(os.path.dirname(__file__), '../data', 'street.jpg')

tests/keras2onnx_unit_tests/test_utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,9 @@ def run_image(model, model_files, img_path, model_name='onnx_conversion', rtol=1
284284
return res, msg
285285

286286

287-
def check_bloburl_access(url):
287+
def is_bloburl_access(url):
288288
try:
289289
response = urllib.request.urlopen(url)
290290
return response.getcode() == 200
291-
except urllib.error.URLError as e:
292-
mock_keras2onnx.common.k2o_logger().warning("URLError:", e.code)
291+
except urllib.error.URLError:
293292
return False
294-
except urllib.error.HTTPError as e:
295-
mock_keras2onnx.common.k2o_logger().warning("HTTPError :", e.reason)

0 commit comments

Comments
 (0)