File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
sdks/python/apache_beam/options Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,9 @@ def get_all_options(
320320 while i < len (unknown_args ):
321321 # Treat all unary flags as booleans, and all binary argument values as
322322 # strings.
323+ if not unknown_args [i ].startswith ('-' ):
324+ i += 1
325+ continue
323326 if i + 1 >= len (unknown_args ) or unknown_args [i + 1 ].startswith ('-' ):
324327 split = unknown_args [i ].split ('=' , 1 )
325328 if len (split ) == 1 :
@@ -330,7 +333,7 @@ def get_all_options(
330333 else :
331334 parser .add_argument (unknown_args [i ], type = str )
332335 i += 2
333- parsed_args = parser .parse_args (self ._flags )
336+ parsed_args , _ = parser .parse_known_args (self ._flags )
334337 else :
335338 if unknown_args :
336339 _LOGGER .warning ("Discarding unparseable args: %s" , unknown_args )
Original file line number Diff line number Diff line change @@ -363,11 +363,6 @@ def test_retain_unknown_options_unary_single_dash_store_true(self):
363363 result = options .get_all_options (retain_unknown_options = True )
364364 self .assertEqual (result ['i' ], True )
365365
366- def test_retain_unknown_options_unary_missing_prefix (self ):
367- options = PipelineOptions (['bad_option' ])
368- with self .assertRaises (SystemExit ):
369- options .get_all_options (retain_unknown_options = True )
370-
371366 def test_override_options (self ):
372367 base_flags = ['--num_workers' , '5' ]
373368 options = PipelineOptions (base_flags )
You can’t perform that action at this time.
0 commit comments