tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.49k stars 1.67k forks source link

hub.load() disable cert validation #781

Closed vedsmehta closed 3 years ago

vedsmehta commented 3 years ago

I ran into an error whilst loading a tfhub model saying that certificate verification failed so I made a fork with a disabled cert check. It's ok if you do not merge this

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

vedsmehta commented 3 years ago

@googlebot I signed it!

vedsmehta commented 3 years ago

@akhorlin I updated the file with an optional argument and also some other files. I need help to implement this. I think it will require changing the tf.compat module

Also, here is the full error message:

---------------------------------------------------------------------------
SSLCertVerificationError                  Traceback (most recent call last)
~/anaconda3/lib/python3.8/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1353             try:
-> 1354                 h.request(req.get_method(), req.selector, req.data, headers,
   1355                           encode_chunked=req.has_header('Transfer-encoding'))

~/anaconda3/lib/python3.8/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1254         """Send a complete request to the server."""
-> 1255         self._send_request(method, url, body, headers, encode_chunked)
   1256 

~/anaconda3/lib/python3.8/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1300             body = _encode(body, 'body')
-> 1301         self.endheaders(body, encode_chunked=encode_chunked)
   1302 

~/anaconda3/lib/python3.8/http/client.py in endheaders(self, message_body, encode_chunked)
   1249             raise CannotSendHeader()
-> 1250         self._send_output(message_body, encode_chunked=encode_chunked)
   1251 

~/anaconda3/lib/python3.8/http/client.py in _send_output(self, message_body, encode_chunked)
   1009         del self._buffer[:]
-> 1010         self.send(msg)
   1011 

~/anaconda3/lib/python3.8/http/client.py in send(self, data)
    949             if self.auto_open:
--> 950                 self.connect()
    951             else:

~/anaconda3/lib/python3.8/http/client.py in connect(self)
   1423 
-> 1424             self.sock = self._context.wrap_socket(self.sock,
   1425                                                   server_hostname=server_hostname)

~/anaconda3/lib/python3.8/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,

~/anaconda3/lib/python3.8/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):

~/anaconda3/lib/python3.8/ssl.py in do_handshake(self, block)
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
<ipython-input-43-d1a78dc1ec0a> in <module>
      3 
      4 hub_handle = 'https://tfhub.dev/google/universal-sentence-encoder/4'
----> 5 emebd = hub.load(hub_handle)
      6 embed_samples = embed([
      7     sample_sentence,

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/module_v2.py in load(handle, tags, options)
     90   if not isinstance(handle, str):
     91     raise ValueError("Expected a string, got %s" % handle)
---> 92   module_path = resolve(handle)
     93   is_hub_module_v1 = tf.io.gfile.exists(
     94       native_module.get_module_proto_path(module_path))

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/module_v2.py in resolve(handle)
     45     A string representing the Module path.
     46   """
---> 47   return registry.resolver(handle)
     48 
     49 

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/registry.py in __call__(self, *args, **kwargs)
     49     for impl in reversed(self._impls):
     50       if impl.is_supported(*args, **kwargs):
---> 51         return impl(*args, **kwargs)
     52       else:
     53         fails.append(type(impl).__name__)

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/compressed_module_resolver.py in __call__(self, handle)
     65           response, tmp_dir)
     66 
---> 67     return resolver.atomic_download(handle, download, module_dir,
     68                                     self._lock_file_timeout_sec())
     69 

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/resolver.py in atomic_download(handle, download_fn, module_dir, lock_file_timeout_sec)
    416     logging.info("Downloading TF-Hub Module '%s'.", handle)
    417     tf.compat.v1.gfile.MakeDirs(tmp_dir)
--> 418     download_fn(handle, tmp_dir)
    419     # Write module descriptor to capture information about which module was
    420     # downloaded by whom and when. The file stored at the same level as a

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/compressed_module_resolver.py in download(handle, tmp_dir)
     61       request = urllib.request.Request(
     62           self._append_compressed_format_query(handle))
---> 63       response = self._call_urlopen(request)
     64       return resolver.DownloadManager(handle).download_and_uncompress(
     65           response, tmp_dir)

~/anaconda3/lib/python3.8/site-packages/tensorflow_hub/resolver.py in _call_urlopen(self, request)
    520     # Overriding this method allows setting SSL context in Python 3.
    521     if self._context is None:
--> 522       return urllib.request.urlopen(request)
    523     else:
    524       return urllib.request.urlopen(request, context=self._context)

~/anaconda3/lib/python3.8/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

~/anaconda3/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
    523 
    524         sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 525         response = self._open(req, data)
    526 
    527         # post-process response

~/anaconda3/lib/python3.8/urllib/request.py in _open(self, req, data)
    540 
    541         protocol = req.type
--> 542         result = self._call_chain(self.handle_open, protocol, protocol +
    543                                   '_open', req)
    544         if result:

~/anaconda3/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    500         for handler in handlers:
    501             func = getattr(handler, meth_name)
--> 502             result = func(*args)
    503             if result is not None:
    504                 return result

~/anaconda3/lib/python3.8/urllib/request.py in https_open(self, req)
   1395 
   1396         def https_open(self, req):
-> 1397             return self.do_open(http.client.HTTPSConnection, req,
   1398                 context=self._context, check_hostname=self._check_hostname)
   1399 

~/anaconda3/lib/python3.8/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1355                           encode_chunked=req.has_header('Transfer-encoding'))
   1356             except OSError as err: # timeout error
-> 1357                 raise URLError(err)
   1358             r = h.getresponse()
   1359         except:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)>
vedsmehta commented 3 years ago

Ok, I reverted my changes and have written an environment variable in module_v2.py. I used it in the HttpBaseResolver class in resolver.py file along with logic for disabling the cert. No new dependencies needed

vedsmehta commented 3 years ago

Also, the error that I got (the one above) is gone with the new changes I made.

vedsmehta commented 3 years ago

All Tests Passed:

Starting local Bazel server and connecting to it...
DEBUG: Rule 'com_google_protobuf' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1558721209 -0700"
DEBUG: Repository com_google_protobuf instantiated at:
  /Users/vedsm/OneDrive/vedant_code/repositories/hub/WORKSPACE:21:15: in <toplevel>
Repository rule git_repository defined at:
  /private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
INFO: Analyzed target //tensorflow_hub:compressed_module_resolver_test (28 packages loaded, 813 targets configured).
INFO: Found 1 test target...
INFO: From Linking external/com_google_protobuf/libprotobuf.a [for host]:
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/host/bin/external/com_google_protobuf/_objs/protobuf/error_listener.o has no symbols
INFO: From Linking external/com_google_protobuf/libprotobuf_lite.a [for host]:
/Library/Developer/CommandLineTools/usr/bin/libtool: file: bazel-out/host/bin/external/com_google_protobuf/_objs/protobuf_lite/io_win32.o has no symbols
Target //tensorflow_hub:compressed_module_resolver_test up-to-date:
  bazel-bin/tensorflow_hub/compressed_module_resolver_test
INFO: Elapsed time: 170.636s, Critical Path: 65.03s
INFO: 204 processes: 18 internal, 186 darwin-sandbox.
INFO: Build completed successfully, 204 total actions
//tensorflow_hub:compressed_module_resolver_test                         PASSED in 32.3s

INFO: Build completed successfully, 204 total actions

(terminal output)

vedsmehta commented 3 years ago

Hey @WGierke is this the correct way to implement the test?

  @parameterized.parameters((None, ssl.CERT_REQUIRED), ("TRUE", ssl.CERT_REQUIRED), ("true", ssl.CERT_NONE))
  def testGetModulePathTarGz_withEnvVariable(self, env_value):
    with unittest.mock.patch.dict(os.environ, {resolver._TFHUB_DISABLE_CERT_VALIDATION: env_value}):
      FLAGS.tfhub_cache_dir = os.path.join(self.get_temp_dir(), "cache_dir")
      http_resolver = compressed_module_resolver.HttpCompressedFileResolver()
      path = http_resolver(self.module_handle)
      files = os.listdir(path)
      expected_cert = ssl.create_default_context()
      expected_cert.verify_mode = env_value
      if expected_cert.verify_mode == ssl.CERT_NONE:
        expected_cert.check_hostname = False
      self.assertEqual(http_resolver._context, expected_cert)
      self.assertListEqual(sorted(files), ["file1", "file2", "file3"])

I am not familiar with absl and unittest.mock in python so please excuse any mistakes. When I tried to test this, this function failed.

vedsmehta commented 3 years ago

Okay, Nevermind. I tweaked the function a bit and here is the test.log file in bazel-testlogs/tensorflow_hub/compressed_module_resolver_test

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //tensorflow_hub:compressed_module_resolver_test
-----------------------------------------------------------------------------
Running tests under Python 3.8.8: /Users/vedsm/anaconda3/bin/python3
[ RUN      ] HttpCompressedFileResolverTest.testAbandondedLockFile
I0724 00:59:45.078717 4607753728 resolver.py:108] Using /private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/sandbox/darwin-sandbox/387/execroot/org_tensorflow_hub/_tmp/4feebb7e35207a842bb3792d8f5d0a69qpkntezc/tmp08scg1m8/cache_dir to cache modules.
I0724 00:59:45.093059 4607753728 resolver.py:308] Module 'http://localhost:54655/mock_module.tar.gz' already being downloaded by 'Vedants-MacBook-Air.local.11297.a730fb4f65d94cc9b16fa0727cd013fd'. Waiting.
W0724 01:00:05.112555 4607753728 resolver.py:323] Deleting lock file /private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/sandbox/darwin-sandbox/387/execroot/org_tensorflow_hub/_tmp/4feebb7e35207a842bb3792d8f5d0a69qpkntezc/tmp08scg1m8/cache_dir/9a9c2215af1d7b99ecf59a4c46c3892562a87579.lock due to inactivity.
I0724 01:00:10.117922 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54655/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.137107 4607753728 resolver.py:157] Downloaded http://localhost:54655/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.138082 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54655/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testAbandondedLockFile
[ RUN      ] HttpCompressedFileResolverTest.testAppendFormatQuery
[       OK ] HttpCompressedFileResolverTest.testAppendFormatQuery
[ RUN      ] HttpCompressedFileResolverTest.testCorruptedArchive
I0724 01:00:10.177722 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54684/bad_archive.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /bad_archive.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.184937 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54685/bad_archive.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /bad_archive.tar.gz?tf-hub-format=compressed HTTP/1.1" 301 -
::1 - - [24/Jul/2021 01:00:10] "GET / HTTP/1.1" 200 -
[       OK ] HttpCompressedFileResolverTest.testCorruptedArchive
[ RUN      ] HttpCompressedFileResolverTest.testGetModuleFromSmartLocation
I0724 01:00:10.203159 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54692/mock_module'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module?tf-hub-format=compressed HTTP/1.1" 301 -
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz HTTP/1.1" 200 -
I0724 01:00:10.208107 4607753728 resolver.py:157] Downloaded http://localhost:54692/mock_module, Total size: 15B
I0724 01:00:10.208645 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54692/mock_module'.
[       OK ] HttpCompressedFileResolverTest.testGetModuleFromSmartLocation
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTar
I0724 01:00:10.220226 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54695/mock_module.tar'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.223665 4607753728 resolver.py:157] Downloaded http://localhost:54695/mock_module.tar, Total size: 15B
I0724 01:00:10.224169 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54695/mock_module.tar'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTar
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz
I0724 01:00:10.236785 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54699/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.240232 4607753728 resolver.py:157] Downloaded http://localhost:54699/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.240741 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54699/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable0 ('TRUE', <VerifyMode.CERT_REQUIRED: 2>)
I0724 01:00:10.256101 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54703/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.260398 4607753728 resolver.py:157] Downloaded http://localhost:54703/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.261408 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54703/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable0 ('TRUE', <VerifyMode.CERT_REQUIRED: 2>)
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable1 ('true', <VerifyMode.CERT_NONE: 0>)
W0724 01:00:10.281562 4607753728 resolver.py:538] Warning: Not using certificate validation to resolve handle.
I0724 01:00:10.282496 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54707/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.286350 4607753728 resolver.py:157] Downloaded http://localhost:54707/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.286949 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54707/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable1 ('true', <VerifyMode.CERT_NONE: 0>)
[ RUN      ] HttpCompressedFileResolverTest.testIsTarFile
[       OK ] HttpCompressedFileResolverTest.testIsTarFile
[ RUN      ] HttpCompressedFileResolverTest.testModuleAlreadyDownloaded
I0724 01:00:10.315479 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54714/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.319753 4607753728 resolver.py:157] Downloaded http://localhost:54714/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.320432 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54714/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testModuleAlreadyDownloaded
[ RUN      ] HttpCompressedFileResolverTest.testModuleDescriptor
I0724 01:00:10.332229 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54718/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.335523 4607753728 resolver.py:157] Downloaded http://localhost:54718/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.336062 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54718/mock_module.tar.gz'.
/private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/sandbox/darwin-sandbox/387/execroot/org_tensorflow_hub/bazel-out/darwin-fastbuild/bin/tensorflow_hub/compressed_module_resolver_test.runfiles/org_tensorflow_hub/tensorflow_hub/compressed_module_resolver_test.py:107: DeprecationWarning: Please use assertRegex instead.
  self.assertRegexpMatches(desc, "Module: %s\n"
[       OK ] HttpCompressedFileResolverTest.testModuleDescriptor
[ RUN      ] HttpCompressedFileResolverTest.testNoCacheDirSet
I0724 01:00:10.351268 4607753728 resolver.py:419] Downloading TF-Hub Module 'http://localhost:54722/mock_module.tar.gz'.
::1 - - [24/Jul/2021 01:00:10] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0724 01:00:10.354851 4607753728 resolver.py:157] Downloaded http://localhost:54722/mock_module.tar.gz, Total size: 15B
I0724 01:00:10.355662 4607753728 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:54722/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testNoCacheDirSet
[ RUN      ] HttpCompressedFileResolverTest.test_session
WARNING:tensorflow:From /Users/vedsm/anaconda3/lib/python3.8/contextlib.py:83: TensorFlowTestCase.test_session (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `self.session()` or `self.cached_session()` instead.
W0724 01:00:10.359820 4607753728 deprecation.py:333] From /Users/vedsm/anaconda3/lib/python3.8/contextlib.py:83: TensorFlowTestCase.test_session (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `self.session()` or `self.cached_session()` instead.
[       OK ] HttpCompressedFileResolverTest.test_session
----------------------------------------------------------------------
Ran 13 tests in 25.305s

OK
vedsmehta commented 3 years ago

New test log (everyhting passed)

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //tensorflow_hub:compressed_module_resolver_test
-----------------------------------------------------------------------------
Running tests under Python 3.8.8: /Users/vedsm/anaconda3/bin/python3
[ RUN      ] HttpCompressedFileResolverTest.testAbandondedLockFile
I0726 14:12:42.680810 4449340928 resolver.py:108] Using /private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/sandbox/darwin-sandbox/186/execroot/org_tensorflow_hub/_tmp/4feebb7e35207a842bb3792d8f5d0a690f07h_zv/tmpk9yk0zi9/cache_dir to cache modules.
I0726 14:12:42.696817 4449340928 resolver.py:308] Module 'http://localhost:52058/mock_module.tar.gz' already being downloaded by 'Vedants-MacBook-Air.local.33174.0a7b2a6f68d1473b8fe54d46688fda0c'. Waiting.
W0726 14:13:02.716844 4449340928 resolver.py:323] Deleting lock file /private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/sandbox/darwin-sandbox/186/execroot/org_tensorflow_hub/_tmp/4feebb7e35207a842bb3792d8f5d0a690f07h_zv/tmpk9yk0zi9/cache_dir/20c05bcb060af64bd75f5be8c5784bcce0974477.lock due to inactivity.
I0726 14:13:07.724232 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52058/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.744118 4449340928 resolver.py:157] Downloaded http://localhost:52058/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.745102 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52058/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testAbandondedLockFile
[ RUN      ] HttpCompressedFileResolverTest.testAppendFormatQuery
[       OK ] HttpCompressedFileResolverTest.testAppendFormatQuery
[ RUN      ] HttpCompressedFileResolverTest.testCorruptedArchive
I0726 14:13:07.788872 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52080/bad_archive.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /bad_archive.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.793944 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52081/bad_archive.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /bad_archive.tar.gz?tf-hub-format=compressed HTTP/1.1" 301 -
::1 - - [26/Jul/2021 14:13:07] "GET / HTTP/1.1" 200 -
[       OK ] HttpCompressedFileResolverTest.testCorruptedArchive
[ RUN      ] HttpCompressedFileResolverTest.testGetModuleFromSmartLocation
I0726 14:13:07.812916 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52088/mock_module'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module?tf-hub-format=compressed HTTP/1.1" 301 -
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz HTTP/1.1" 200 -
I0726 14:13:07.817946 4449340928 resolver.py:157] Downloaded http://localhost:52088/mock_module, Total size: 15B
I0726 14:13:07.818501 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52088/mock_module'.
[       OK ] HttpCompressedFileResolverTest.testGetModuleFromSmartLocation
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTar
I0726 14:13:07.831431 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52091/mock_module.tar'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.834895 4449340928 resolver.py:157] Downloaded http://localhost:52091/mock_module.tar, Total size: 15B
I0726 14:13:07.835407 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52091/mock_module.tar'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTar
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz
I0726 14:13:07.846376 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52095/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.849862 4449340928 resolver.py:157] Downloaded http://localhost:52095/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.850462 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52095/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable0 ('', <VerifyMode.CERT_REQUIRED: 2>)
I0726 14:13:07.861891 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52099/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.865320 4449340928 resolver.py:157] Downloaded http://localhost:52099/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.865892 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52099/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable0 ('', <VerifyMode.CERT_REQUIRED: 2>)
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable1 ('TRUE', <VerifyMode.CERT_REQUIRED: 2>)
I0726 14:13:07.880252 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52103/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.883800 4449340928 resolver.py:157] Downloaded http://localhost:52103/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.884314 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52103/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable1 ('TRUE', <VerifyMode.CERT_REQUIRED: 2>)
[ RUN      ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable2 ('true', <VerifyMode.CERT_NONE: 0>)
W0726 14:13:07.894824 4449340928 resolver.py:544] Disabled certificate validation for resolving handles.
I0726 14:13:07.895672 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52107/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.899377 4449340928 resolver.py:157] Downloaded http://localhost:52107/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.899935 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52107/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testGetModulePathTarGz_withEnvVariable2 ('true', <VerifyMode.CERT_NONE: 0>)
[ RUN      ] HttpCompressedFileResolverTest.testIsTarFile
[       OK ] HttpCompressedFileResolverTest.testIsTarFile
[ RUN      ] HttpCompressedFileResolverTest.testModuleAlreadyDownloaded
I0726 14:13:07.914602 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52114/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.920535 4449340928 resolver.py:157] Downloaded http://localhost:52114/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.921042 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52114/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testModuleAlreadyDownloaded
[ RUN      ] HttpCompressedFileResolverTest.testModuleDescriptor
I0726 14:13:07.932130 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52118/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.935543 4449340928 resolver.py:157] Downloaded http://localhost:52118/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.936047 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52118/mock_module.tar.gz'.
/private/var/tmp/_bazel_vedsm/beefc41e962a9e1e5d0a7a590886fc23/sandbox/darwin-sandbox/186/execroot/org_tensorflow_hub/bazel-out/darwin-fastbuild/bin/tensorflow_hub/compressed_module_resolver_test.runfiles/org_tensorflow_hub/tensorflow_hub/compressed_module_resolver_test.py:107: DeprecationWarning: Please use assertRegex instead.
  self.assertRegexpMatches(desc, "Module: %s\n"
[       OK ] HttpCompressedFileResolverTest.testModuleDescriptor
[ RUN      ] HttpCompressedFileResolverTest.testNoCacheDirSet
I0726 14:13:07.947919 4449340928 resolver.py:419] Downloading TF-Hub Module 'http://localhost:52122/mock_module.tar.gz'.
::1 - - [26/Jul/2021 14:13:07] "GET /mock_module.tar.gz?tf-hub-format=compressed HTTP/1.1" 200 -
I0726 14:13:07.951921 4449340928 resolver.py:157] Downloaded http://localhost:52122/mock_module.tar.gz, Total size: 15B
I0726 14:13:07.952426 4449340928 resolver.py:434] Downloaded TF-Hub Module 'http://localhost:52122/mock_module.tar.gz'.
[       OK ] HttpCompressedFileResolverTest.testNoCacheDirSet
[ RUN      ] HttpCompressedFileResolverTest.test_session
WARNING:tensorflow:From /Users/vedsm/anaconda3/lib/python3.8/contextlib.py:83: TensorFlowTestCase.test_session (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `self.session()` or `self.cached_session()` instead.
W0726 14:13:07.959989 4449340928 deprecation.py:333] From /Users/vedsm/anaconda3/lib/python3.8/contextlib.py:83: TensorFlowTestCase.test_session (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `self.session()` or `self.cached_session()` instead.
[       OK ] HttpCompressedFileResolverTest.test_session
----------------------------------------------------------------------
Ran 14 tests in 25.301s

OK
vedsmehta commented 3 years ago

Thank you!