Example #1
0
    def testCanInitializeTFInstalled(self):
        orig_find_spec = importlib.util.find_spec

        def tf_import_mock(name, *args, **kwargs):
            if name == "tensorflow":
                return None
            return orig_find_spec(name, *args, **kwargs)

        with mock.patch("importlib.util.find_spec", side_effect=tf_import_mock):
            assert not TFProfiler.can_initialize()
Example #2
0
    def testCanInitializeNoProfilePlugin(self):
        orig_find_spec = importlib.util.find_spec

        def plugin_import_mock(name, *args, **kwargs):
            if name == "tensorboard_plugin_profile":
                return None
            return orig_find_spec(name, *args, **kwargs)

        with mock.patch("importlib.util.find_spec", side_effect=plugin_import_mock):
            assert not TFProfiler.can_initialize()
Example #3
0
 def testCanInitialize(self):
     assert TFProfiler.can_initialize()
Example #4
0
    def testCanInitializeOldTFVersion(self):
        import tensorflow

        with mock.patch.dict(tensorflow.__dict__, {"__version__": "2.3.0"}):
            assert not TFProfiler.can_initialize()
Example #5
0
 def testCanInitializeNoClusterSpec(self):
     tf_profiler.environment_variables.cluster_spec = None
     assert not TFProfiler.can_initialize()
Example #6
0
 def testCanInitializeJobIdUnset(self):
     tf_profiler.environment_variables.cloud_ml_job_id = None
     assert not TFProfiler.can_initialize()
Example #7
0
 def testCanInitializeTBResourceNameUnset(self):
     tf_profiler.environment_variables.tensorboard_resource_name = None
     assert not TFProfiler.can_initialize()
Example #8
0
 def testCanInitializeTBAPIuriUnset(self):
     tf_profiler.environment_variables.tensorboard_api_uri = None
     assert not TFProfiler.can_initialize()
Example #9
0
 def testCanInitializeTBLogDirUnset(self):
     tf_profiler.environment_variables.tensorboard_log_dir = None
     assert not TFProfiler.can_initialize()
Example #10
0
 def testCanInitializeProfilerPortUnset(self):
     tf_profiler.environment_variables.tf_profiler_port = None
     assert not TFProfiler.can_initialize()