本文整理汇总了Python中absl.testing.flagsaver.save_flag_values方法的典型用法代码示例。如果您正苦于以下问题:Python flagsaver.save_flag_values方法的具体用法?Python flagsaver.save_flag_values怎么用?Python flagsaver.save_flag_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类absl.testing.flagsaver
的用法示例。
在下文中一共展示了flagsaver.save_flag_values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def setUp(self):
super(BeyondcorpTest, self).setUp()
self.__saved_flags = flagsaver.save_flag_values()
mock_wmi = mock.patch.object(
beyondcorp.hw_info.wmi_query, 'WMIQuery', autospec=True)
self.addCleanup(mock_wmi.stop)
mock_wmi.start()
self.filesystem = fake_filesystem.FakeFilesystem()
self.filesystem.CreateFile(r'C:\seed.json', contents=_TEST_SEED)
self.filesystem.CreateFile(beyondcorp.constants.USB_WIM, contents=_TEST_WIM)
beyondcorp.os = fake_filesystem.FakeOsModule(self.filesystem)
beyondcorp.open = fake_filesystem.FakeFileOpen(self.filesystem)
self.beyondcorp = beyondcorp.BeyondCorp()
示例2: save_flag_values
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def save_flag_values(flag_values=FLAGS):
"""Returns copy of flag values as a dict.
Args:
flag_values: FlagValues, the FlagValues instance with which the flag will
be saved. This should almost never need to be overridden.
Returns:
Dictionary mapping keys to values. Keys are flag names, values are
corresponding __dict__ members. E.g. {'key': value_dict, ...}.
"""
return {name: _copy_flag_dict(flag_values[name]) for name in flag_values}
示例3: __enter__
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def __enter__(self):
self._saved_flag_values = save_flag_values(FLAGS)
try:
for name, value in six.iteritems(self._overrides):
setattr(FLAGS, name, value)
except:
# It may fail because of flag validators.
restore_flag_values(self._saved_flag_values, FLAGS)
raise
示例4: test_save_flag_value
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def test_save_flag_value(self):
# First save the flag values.
saved_flag_values = flagsaver.save_flag_values()
# Now mutate the flag's value field and check that it changed.
FLAGS.flagsaver_test_flag0 = 'new value'
self.assertEqual('new value', FLAGS.flagsaver_test_flag0)
# Now restore the flag to its original value.
flagsaver.restore_flag_values(saved_flag_values)
self.assertEqual('unchanged0', FLAGS.flagsaver_test_flag0)
示例5: test_save_flag_default
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def test_save_flag_default(self):
# First save the flag.
saved_flag_values = flagsaver.save_flag_values()
# Now mutate the flag's default field and check that it changed.
FLAGS.set_default('flagsaver_test_flag0', 'new_default')
self.assertEqual('new_default', FLAGS['flagsaver_test_flag0'].default)
# Now restore the flag's default field.
flagsaver.restore_flag_values(saved_flag_values)
self.assertEqual('unchanged0', FLAGS['flagsaver_test_flag0'].default)
示例6: test_restore_after_parse
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def test_restore_after_parse(self):
# First save the flag.
saved_flag_values = flagsaver.save_flag_values()
# Sanity check (would fail if called with --flagsaver_test_flag0).
self.assertEqual(0, FLAGS['flagsaver_test_flag0'].present)
# Now populate the flag and check that it changed.
FLAGS['flagsaver_test_flag0'].parse('new value')
self.assertEqual('new value', FLAGS['flagsaver_test_flag0'].value)
self.assertEqual(1, FLAGS['flagsaver_test_flag0'].present)
# Now restore the flag to its original value.
flagsaver.restore_flag_values(saved_flag_values)
self.assertEqual('unchanged0', FLAGS['flagsaver_test_flag0'].value)
self.assertEqual(0, FLAGS['flagsaver_test_flag0'].present)
示例7: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Sets up and resets flags before each test."""
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.DEBUG)
if NCFKerasBenchmarkBase.local_flags is None:
ncf_common.define_ncf_flags()
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
core.set_defaults(**self.default_flags)
saved_flag_values = flagsaver.save_flag_values()
NCFKerasBenchmarkBase.local_flags = saved_flag_values
else:
flagsaver.restore_flag_values(NCFKerasBenchmarkBase.local_flags)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:14,代码来源:ncf_keras_benchmark.py
示例8: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Sets up and resets flags before each test."""
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.DEBUG)
if PerfZeroBenchmark.local_flags is None:
for flag_method in self.flag_methods:
flag_method()
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
# Overrides flag values with defaults for the class of tests.
for k, v in self.default_flags.items():
setattr(FLAGS, k, v)
saved_flag_values = flagsaver.save_flag_values()
PerfZeroBenchmark.local_flags = saved_flag_values
else:
flagsaver.restore_flag_values(PerfZeroBenchmark.local_flags)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:17,代码来源:perfzero_benchmark.py
示例9: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Sets up and resets flags before each test."""
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.DEBUG)
if EstimatorBenchmark.local_flags is None:
for flag_method in self.flag_methods:
flag_method()
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
# Overrides flag values with defaults for the class of tests.
for k, v in self.default_flags.items():
setattr(FLAGS, k, v)
saved_flag_values = flagsaver.save_flag_values()
EstimatorBenchmark.local_flags = saved_flag_values
else:
flagsaver.restore_flag_values(EstimatorBenchmark.local_flags)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:17,代码来源:estimator_benchmark.py
示例10: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Sets up and resets flags before each test."""
self.timer_callback = BenchmarkTimerCallback()
if BertBenchmarkBase.local_flags is None:
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
saved_flag_values = flagsaver.save_flag_values()
BertBenchmarkBase.local_flags = saved_flag_values
else:
flagsaver.restore_flag_values(BertBenchmarkBase.local_flags)
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:13,代码来源:benchmark_utils.py
示例11: setUp
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def setUp(self):
temp_dir = self.get_temp_dir()
if TransformerTaskTest.local_flags is None:
misc.define_transformer_flags()
# Loads flags, array cannot be blank.
flags.FLAGS(['foo'])
TransformerTaskTest.local_flags = flagsaver.save_flag_values()
else:
flagsaver.restore_flag_values(TransformerTaskTest.local_flags)
FLAGS.model_dir = os.path.join(temp_dir, FIXED_TIMESTAMP)
FLAGS.param_set = 'tiny'
FLAGS.use_synthetic_data = True
FLAGS.steps_between_evals = 1
FLAGS.train_steps = 2
FLAGS.validation_steps = 1
FLAGS.batch_size = 8
FLAGS.num_gpus = 1
FLAGS.distribution_strategy = 'off'
FLAGS.dtype = 'fp32'
self.model_dir = FLAGS.model_dir
self.temp_dir = temp_dir
self.vocab_file = os.path.join(temp_dir, 'vocab')
self.vocab_size = misc.get_model_params(FLAGS.param_set, 0)['vocab_size']
self.bleu_source = os.path.join(temp_dir, 'bleu_source')
self.bleu_ref = os.path.join(temp_dir, 'bleu_ref')
self.orig_policy = (
tf.compat.v2.keras.mixed_precision.experimental.global_policy())
开发者ID:ShivangShekhar,项目名称:Live-feed-object-device-identification-using-Tensorflow-and-OpenCV,代码行数:29,代码来源:transformer_main_test.py
示例12: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
tf.logging.set_verbosity(tf.logging.DEBUG)
if EstimatorCifar10BenchmarkTests.local_flags is None:
cifar_main.define_cifar_flags()
# Loads flags to get defaults to then override.
flags.FLAGS(['foo'])
saved_flag_values = flagsaver.save_flag_values()
EstimatorCifar10BenchmarkTests.local_flags = saved_flag_values
return
flagsaver.restore_flag_values(EstimatorCifar10BenchmarkTests.local_flags)
示例13: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Setups up and resets flags before each test."""
tf.logging.set_verbosity(tf.logging.DEBUG)
if KerasImagenetBenchmarkTests.local_flags is None:
keras_common.define_keras_flags()
imagenet_main.define_imagenet_flags()
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
saved_flag_values = flagsaver.save_flag_values()
KerasImagenetBenchmarkTests.local_flags = saved_flag_values
return
flagsaver.restore_flag_values(KerasImagenetBenchmarkTests.local_flags)
示例14: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Setups up and resets flags before each test."""
tf.logging.set_verbosity(tf.logging.DEBUG)
if KerasCifar10BenchmarkTests.local_flags is None:
keras_common.define_keras_flags()
cifar_main.define_cifar_flags()
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
saved_flag_values = flagsaver.save_flag_values()
KerasCifar10BenchmarkTests.local_flags = saved_flag_values
return
flagsaver.restore_flag_values(KerasCifar10BenchmarkTests.local_flags)
示例15: _setup
# 需要导入模块: from absl.testing import flagsaver [as 别名]
# 或者: from absl.testing.flagsaver import save_flag_values [as 别名]
def _setup(self):
"""Sets up and resets flags before each test."""
logging.set_verbosity(logging.INFO)
if NCFKerasBenchmarkBase.local_flags is None:
ncf_common.define_ncf_flags()
# Loads flags to get defaults to then override. List cannot be empty.
flags.FLAGS(['foo'])
core.set_defaults(**self.default_flags)
saved_flag_values = flagsaver.save_flag_values()
NCFKerasBenchmarkBase.local_flags = saved_flag_values
else:
flagsaver.restore_flag_values(NCFKerasBenchmarkBase.local_flags)