forked from tensorflow/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to use default tags with hub.load() when none are specified.
PiperOrigin-RevId: 276676596
- Loading branch information
1 parent
eb51c5a
commit 27db714
Showing
8 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright 2019 The TensorFlow Hub Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
"""Tests for tensorflow_hub.module_v2.""" | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
# pylint:disable=g-import-not-at-top,g-statement-before-imports | ||
try: | ||
import mock as mock | ||
except ImportError: | ||
import unittest.mock as mock | ||
# pylint:disable=g-import-not-at-top,g-statement-before-imports | ||
|
||
from absl.testing import parameterized | ||
import tensorflow as tf | ||
from tensorflow_hub import config | ||
from tensorflow_hub import module_v2 | ||
from tensorflow_hub import test_utils | ||
|
||
# Initialize resolvers and loaders. | ||
config._run() | ||
|
||
|
||
class ModuleV2Test(tf.test.TestCase, parameterized.TestCase): | ||
|
||
@parameterized.named_parameters( | ||
('v1_implicit_tags', 'hub_module_v1_mini', None, True), | ||
('v1_explicit_tags', 'hub_module_v1_mini', [], True), | ||
('v2_implicit_tags', 'saved_model_v2_mini', None, False), | ||
('v2_explicit_tags', 'saved_model_v2_mini', ['serve'], False), | ||
) | ||
def test_load(self, module_name, tags, is_hub_module_v1): | ||
path = test_utils.get_test_data_path(module_name) | ||
m = module_v2.load(path, tags) | ||
self.assertEqual(m._is_hub_module_v1, is_hub_module_v1) | ||
|
||
@mock.patch.object(module_v2, 'tf_v1') | ||
def test_load_with_old_tensorflow_raises_error(self, tf_v1_mock): | ||
tf_v1_mock.saved_model = None | ||
with self.assertRaises(NotImplementedError): | ||
module_v2.load('dummy_module_name') | ||
|
||
|
||
if __name__ == '__main__': | ||
tf.test.main() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Binary file not shown.
Binary file added
BIN
+126 Bytes
tensorflow_hub/testdata/saved_model_v2_mini/variables/variables.data-00000-of-00001
Binary file not shown.
Binary file added
BIN
+199 Bytes
tensorflow_hub/testdata/saved_model_v2_mini/variables/variables.index
Binary file not shown.