Skip to content

Commit

Permalink
Change Map name and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandInguva committed Mar 8, 2022
1 parent cb24183 commit 078f58b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions sdks/python/apache_beam/options/pipeline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@

_LOGGER = logging.getLogger(__name__)

# Map the boolean option with the flag_name for the flags that have a
# destination(dest) different from the flag name and the
# default value is None in parser.add_argument().
_FLAGS_WITH_DIFFERENT_DEST = {'use_public_ips': 'no_use_public_ips'}
# Map defined with option names to flag names for boolean options
# that have a destination(dest) in parser.add_argument() different
# from the flag name and whose default value is `None`.
_FLAG_THAT_SETS_FALSE_VALUE = {'use_public_ips': 'no_use_public_ips'}


def _static_value_provider_of(value_type):
Expand Down Expand Up @@ -259,12 +259,12 @@ def from_dictionary(cls, options):
if isinstance(v, bool):
if v:
flags.append('--%s' % k)
elif k in _FLAGS_WITH_DIFFERENT_DEST:
elif k in _FLAG_THAT_SETS_FALSE_VALUE:
# Capture overriding flags, which have a different dest
# from the flag name defined in the parser.add_argument
# Eg: no_use_public_ips, which has the dest=use_public_ips
# different from flag name
flag_that_disables_the_option = (_FLAGS_WITH_DIFFERENT_DEST[k])
flag_that_disables_the_option = (_FLAG_THAT_SETS_FALSE_VALUE[k])
flags.append('--%s' % flag_that_disables_the_option)
elif isinstance(v, list):
for i in v:
Expand Down
6 changes: 3 additions & 3 deletions sdks/python/apache_beam/options/pipeline_options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,15 +687,15 @@ def test_options_store_false_with_different_dest(self):
"to the user. Please specify the dest as the "
"flag_name instead."))
from apache_beam.options.pipeline_options import (
_FLAGS_WITH_DIFFERENT_DEST)
_FLAG_THAT_SETS_FALSE_VALUE)

self.assertDictEqual(
_FLAGS_WITH_DIFFERENT_DEST,
_FLAG_THAT_SETS_FALSE_VALUE,
options_to_flags,
"If you are adding a new boolean flag with default=None,"
" with different dest/option_name from the flag name, please add "
"the dest and the flag name to the map "
"_FLAGS_WITH_DIFFERENT_DEST in PipelineOptions.py")
"_FLAG_THAT_SETS_FALSE_VALUE in PipelineOptions.py")


if __name__ == '__main__':
Expand Down

0 comments on commit 078f58b

Please sign in to comment.