Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAM-7746] Fix a typing issue where SourceBase was assumed to have a coder attribute #10590

Merged
merged 1 commit into from
Jan 17, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdks/python/apache_beam/io/iobase.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,13 @@ def get_windowing(self, unused_inputs):

def _infer_output_coder(self, input_type=None, input_coder=None):
# type: (...) -> Optional[coders.Coder]
from apache_beam.runners.dataflow.native_io import iobase as dataflow_io
if isinstance(self.source, BoundedSource):
return self.source.default_output_coder()
else:
elif isinstance(self.source, dataflow_io.NativeSource):
return self.source.coder
else:
return None

def display_data(self):
return {'source': DisplayDataItem(self.source.__class__,
Expand Down
6 changes: 6 additions & 0 deletions sdks/python/apache_beam/runners/dataflow/native_io/iobase.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@

import logging
from builtins import object
from typing import TYPE_CHECKING
from typing import Optional

from apache_beam import pvalue
from apache_beam.io import iobase
from apache_beam.transforms import ptransform
from apache_beam.transforms.display import HasDisplayData

if TYPE_CHECKING:
from apache_beam import coders

_LOGGER = logging.getLogger(__name__)


Expand All @@ -58,6 +63,7 @@ class NativeSource(iobase.SourceBase):

This class is deprecated and should not be used to define new sources.
"""
coder = None # type: Optional[coders.Coder]

def reader(self):
"""Returns a NativeSourceReader instance associated with this source."""
Expand Down