beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [beam] ibzib commented on a change in pull request #11189: [BEAM-9446] Retain unknown arguments when using uber jar job server.
Date Mon, 23 Mar 2020 18:55:57 GMT
ibzib commented on a change in pull request #11189: [BEAM-9446] Retain unknown arguments when
using uber jar job server.
URL: https://github.com/apache/beam/pull/11189#discussion_r396684486
 
 

 ##########
 File path: sdks/python/apache_beam/options/pipeline_options.py
 ##########
 @@ -285,10 +289,25 @@ def get_all_options(
       cls._add_argparse_args(parser)  # pylint: disable=protected-access
     if add_extra_args_fn:
       add_extra_args_fn(parser)
+
     known_args, unknown_args = parser.parse_known_args(self._flags)
-    if unknown_args:
-      _LOGGER.warning("Discarding unparseable args: %s", unknown_args)
-    result = vars(known_args)
+    if retain_unknown_options:
+      i = 0
+      while i < len(unknown_args):
+        # Treat all unary flags as booleans, and all binary argument values as
+        # strings.
+        if i + 1 >= len(unknown_args) or unknown_args[i + 1].startswith('--'):
 
 Review comment:
   I guess I should change it to `-`, not `--`. `-` is the default prefix for argparse, and
AFAICT that is true for Beam as well, even though most (all?) pipeline options use `--`.
   https://docs.python.org/3/library/argparse.html#prefix-chars
   
   So then the question becomes "Should we always check a parameter name starts with `-`?"
And the answer is we don't have to, because the call to parse_args will do that for us. `test_retain_unknown_options_unary_missing_prefix`
tests that.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message