Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdks/python/apache_beam/options/pipeline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ def get_all_options(
while i < len(unknown_args):
# Treat all unary flags as booleans, and all binary argument values as
# strings.
if not unknown_args[i].startswith('-'):
i += 1
continue
Comment on lines +323 to +325
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we start looking at i+1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will look at i+1, which will be a fresh argument, in the next iteration of the loop.

if i + 1 >= len(unknown_args) or unknown_args[i + 1].startswith('-'):
split = unknown_args[i].split('=', 1)
if len(split) == 1:
Expand All @@ -330,7 +333,7 @@ def get_all_options(
else:
parser.add_argument(unknown_args[i], type=str)
i += 2
parsed_args = parser.parse_args(self._flags)
parsed_args, _ = parser.parse_known_args(self._flags)
else:
if unknown_args:
_LOGGER.warning("Discarding unparseable args: %s", unknown_args)
Expand Down
5 changes: 0 additions & 5 deletions sdks/python/apache_beam/options/pipeline_options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ def test_retain_unknown_options_unary_single_dash_store_true(self):
result = options.get_all_options(retain_unknown_options=True)
self.assertEqual(result['i'], True)

def test_retain_unknown_options_unary_missing_prefix(self):
options = PipelineOptions(['bad_option'])
with self.assertRaises(SystemExit):
options.get_all_options(retain_unknown_options=True)

def test_override_options(self):
base_flags = ['--num_workers', '5']
options = PipelineOptions(base_flags)
Expand Down