Python absl.flags.declare_key_flag() Examples
The following are 18
code examples of absl.flags.declare_key_flag().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
absl.flags
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: core.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #2
Source File: core.py From nsfw with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #3
Source File: core.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #4
Source File: core.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #5
Source File: core.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #6
Source File: core.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #7
Source File: core.py From models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #8
Source File: core.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #9
Source File: core.py From models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #10
Source File: core.py From models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #11
Source File: core.py From models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #12
Source File: core.py From models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #13
Source File: core.py From models with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #14
Source File: core.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def register_key_flags_in_core(f): """Defines a function in core.py, and registers its key flags. absl uses the location of a flags.declare_key_flag() to determine the context in which a flag is key. By making all declares in core, this allows model main functions to call flags.adopt_module_key_flags() on core and correctly chain key flags. Args: f: The function to be wrapped Returns: The "core-defined" version of the input function. """ def core_fn(*args, **kwargs): key_flags = f(*args, **kwargs) [flags.declare_key_flag(fl) for fl in key_flags] # pylint: disable=expression-not-assigned return core_fn
Example #15
Source File: argparse_flags_test.py From abseil-py with Apache License 2.0 | 5 votes |
def test_help_non_main_module_key_flags(self): flags.DEFINE_string( 'non_main_module_flag', 'default', 'help', module_name='other.module', flag_values=self._absl_flags) flags.declare_key_flag('non_main_module_flag', flag_values=self._absl_flags) parser = argparse_flags.ArgumentParser( inherited_absl_flags=self._absl_flags) help_message = parser.format_help() # Main module key fags are printed in the help message, even if the flag # is defined in another module. self.assertIn('non_main_module_flag', help_message)
Example #16
Source File: module_foo.py From abseil-py with Apache License 2.0 | 5 votes |
def declare_key_flags(flag_values=FLAGS): """Declares a few key flags.""" for flag_name in DECLARED_KEY_FLAGS: flags.declare_key_flag(flag_name, flag_values=flag_values)
Example #17
Source File: benchmark_cnn.py From parallax with Apache License 2.0 | 5 votes |
def define_flags(): """Define a command line flag for each ParamSpec in _DEFAULT_PARAMS.""" define_flag = { 'boolean': flags.DEFINE_boolean, 'float': flags.DEFINE_float, 'integer': flags.DEFINE_integer, 'string': flags.DEFINE_string, } for name, param_spec in six.iteritems(_DEFAULT_PARAMS): if param_spec.flag_type not in define_flag: raise ValueError('Unknown flag_type %s' % param_spec.flag_type) else: define_flag[param_spec.flag_type](name, param_spec.default_value, param_spec.description) flags.declare_key_flag(name)
Example #18
Source File: flags_test.py From abseil-py with Apache License 2.0 | 4 votes |
def test_key_flags(self): flag_values = flags.FlagValues() # Before starting any testing, make sure no flags are already # defined for module_foo and module_bar. self.assertListEqual(self._get_names_of_key_flags(module_foo, flag_values), []) self.assertListEqual(self._get_names_of_key_flags(module_bar, flag_values), []) self.assertListEqual(self._get_names_of_defined_flags(module_foo, flag_values), []) self.assertListEqual(self._get_names_of_defined_flags(module_bar, flag_values), []) # Defines a few flags in module_foo and module_bar. module_foo.define_flags(flag_values=flag_values) try: # Part 1. Check that all flags defined by module_foo are key for # that module, and similarly for module_bar. for module in [module_foo, module_bar]: self._assert_lists_have_same_elements( flag_values._get_flags_defined_by_module(module), flag_values.get_key_flags_for_module(module)) # Also check that each module defined the expected flags. self._assert_lists_have_same_elements( self._get_names_of_defined_flags(module, flag_values), module.names_of_defined_flags()) # Part 2. Check that flags.declare_key_flag works fine. # Declare that some flags from module_bar are key for # module_foo. module_foo.declare_key_flags(flag_values=flag_values) # Check that module_foo has the expected list of defined flags. self._assert_lists_have_same_elements( self._get_names_of_defined_flags(module_foo, flag_values), module_foo.names_of_defined_flags()) # Check that module_foo has the expected list of key flags. self._assert_lists_have_same_elements( self._get_names_of_key_flags(module_foo, flag_values), module_foo.names_of_declared_key_flags()) # Part 3. Check that flags.adopt_module_key_flags works fine. # Trigger a call to flags.adopt_module_key_flags(module_bar) # inside module_foo. This should declare a few more key # flags in module_foo. module_foo.declare_extra_key_flags(flag_values=flag_values) # Check that module_foo has the expected list of key flags. self._assert_lists_have_same_elements( self._get_names_of_key_flags(module_foo, flag_values), module_foo.names_of_declared_key_flags() + module_foo.names_of_declared_extra_key_flags()) finally: module_foo.remove_flags(flag_values=flag_values)