Skip to content

Commit 33a597c

Browse files
committed
fix(pubsub): handle None runner case and improve debug logging
Move debug logging outside error condition and log at debug level instead of warning
1 parent 4433ce6 commit 33a597c

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

sdks/python/apache_beam/io/gcp/pubsub.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ def __init__(self, transform):
582582
runner_name = all_options.get('runner', StandardOptions.DEFAULT_RUNNER)
583583

584584
# Check if it's a DirectRunner variant
585-
if (runner_name in StandardOptions.LOCAL_RUNNERS or
586-
'DirectRunner' in str(runner_name) or
587-
'TestDirectRunner' in str(runner_name)):
585+
if (runner_name is None or
586+
(runner_name in StandardOptions.LOCAL_RUNNERS or 'DirectRunner'
587+
in str(runner_name) or 'TestDirectRunner' in str(runner_name))):
588588
should_raise_error = True
589589
except Exception:
590590
# If we can't determine runner, assume DirectRunner for safety
@@ -598,24 +598,25 @@ def __init__(self, transform):
598598
# If no pipeline options available, fall back to original behavior
599599
should_raise_error = True
600600

601+
# Log debug information for troubleshooting
602+
import logging
603+
runner_info = getattr(
604+
pipeline_options, 'runner',
605+
'None') if pipeline_options else 'No options'
606+
streaming_info = 'Unknown'
607+
if pipeline_options:
608+
try:
609+
standard_options = pipeline_options.view_as(StandardOptions)
610+
streaming_info = 'streaming=%s' % standard_options.streaming
611+
except Exception:
612+
streaming_info = 'streaming=unknown'
613+
614+
logging.debug(
615+
'PubSub unsupported feature check: runner=%s, %s',
616+
runner_info,
617+
streaming_info)
618+
601619
if should_raise_error:
602-
# Log debug information for troubleshooting
603-
import logging
604-
runner_info = getattr(
605-
pipeline_options, 'runner',
606-
'None') if pipeline_options else 'No options'
607-
streaming_info = 'Unknown'
608-
if pipeline_options:
609-
try:
610-
standard_options = pipeline_options.view_as(StandardOptions)
611-
streaming_info = 'streaming=%s' % standard_options.streaming
612-
except Exception:
613-
streaming_info = 'streaming=unknown'
614-
615-
logging.warning(
616-
'PubSub unsupported feature check: runner=%s, %s',
617-
runner_info,
618-
streaming_info)
619620

620621
if transform.id_label:
621622
raise NotImplementedError(

0 commit comments

Comments
 (0)