Repository: incubator-beam Updated Branches: refs/heads/python-sdk d78b38d1d -> e5006991d
Minor cdef value changes. Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/19082adb Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/19082adb Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/19082adb Branch: refs/heads/python-sdk Commit: 19082adb1522365b1f526e8c28a0a04a20744128 Parents: d78b38d Author: Robert Bradshaw <[email protected]> Authored: Thu Jul 21 10:36:36 2016 -0700 Committer: Robert Bradshaw <[email protected]> Committed: Thu Jul 21 17:38:55 2016 -0700 ---------------------------------------------------------------------- sdks/python/apache_beam/runners/common.pxd | 4 ++-- sdks/python/apache_beam/runners/common.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/19082adb/sdks/python/apache_beam/runners/common.pxd ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/runners/common.pxd b/sdks/python/apache_beam/runners/common.pxd index 7191659..e1bf461 100644 --- a/sdks/python/apache_beam/runners/common.pxd +++ b/sdks/python/apache_beam/runners/common.pxd @@ -39,11 +39,11 @@ cdef class DoFnContext(object): cdef object label cdef object state cdef WindowedValue windowed_value - cdef set_element(self, WindowedValue windowed_value) + cpdef set_element(self, WindowedValue windowed_value) cdef class Receiver(object): - cdef receive(self, WindowedValue windowed_value) + cpdef receive(self, WindowedValue windowed_value) cdef class LoggingContext(object): http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/19082adb/sdks/python/apache_beam/runners/common.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/runners/common.py b/sdks/python/apache_beam/runners/common.py index a565645..c6b27bc 100644 --- a/sdks/python/apache_beam/runners/common.py +++ b/sdks/python/apache_beam/runners/common.py @@ -214,15 +214,24 @@ class DoFnContext(object): @property def element(self): - return self.windowed_value.value + if self.windowed_value is None: + raise AttributeError('element not accessible in this context') + else: + return self.windowed_value.value @property def timestamp(self): - return self.windowed_value.timestamp + if self.windowed_value is None: + raise AttributeError('timestamp not accessible in this context') + else: + return self.windowed_value.timestamp @property def windows(self): - return self.windowed_value.windows + if self.windowed_value is None: + raise AttributeError('windows not accessible in this context') + else: + return self.windowed_value.windows def aggregate_to(self, aggregator, input_value): self.state.counter_for(aggregator).update(input_value)
