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()
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()
def testCanInitialize(self): assert TFProfiler.can_initialize()
def testCanInitializeOldTFVersion(self): import tensorflow with mock.patch.dict(tensorflow.__dict__, {"__version__": "2.3.0"}): assert not TFProfiler.can_initialize()
def testCanInitializeNoClusterSpec(self): tf_profiler.environment_variables.cluster_spec = None assert not TFProfiler.can_initialize()
def testCanInitializeJobIdUnset(self): tf_profiler.environment_variables.cloud_ml_job_id = None assert not TFProfiler.can_initialize()
def testCanInitializeTBResourceNameUnset(self): tf_profiler.environment_variables.tensorboard_resource_name = None assert not TFProfiler.can_initialize()
def testCanInitializeTBAPIuriUnset(self): tf_profiler.environment_variables.tensorboard_api_uri = None assert not TFProfiler.can_initialize()
def testCanInitializeTBLogDirUnset(self): tf_profiler.environment_variables.tensorboard_log_dir = None assert not TFProfiler.can_initialize()
def testCanInitializeProfilerPortUnset(self): tf_profiler.environment_variables.tf_profiler_port = None assert not TFProfiler.can_initialize()