Repository: beam
Updated Branches:
  refs/heads/master 1533d7013 -> 96a05a4b4


Add deprecation warning to OldDoFn


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/c0eef135
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/c0eef135
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/c0eef135

Branch: refs/heads/master
Commit: c0eef135e8fca960b7b16b37bbc3e13c52082a72
Parents: 1533d70
Author: Sourabh Bajaj <[email protected]>
Authored: Thu Feb 2 16:39:24 2017 -0800
Committer: Ahmet Altay <[email protected]>
Committed: Thu Feb 2 16:47:27 2017 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/transforms/core.py     | 11 ++++++++---
 sdks/python/apache_beam/typehints/typecheck.py |  8 +++++---
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/c0eef135/sdks/python/apache_beam/transforms/core.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/core.py 
b/sdks/python/apache_beam/transforms/core.py
index 9bafce5..bba6bd9 100644
--- a/sdks/python/apache_beam/transforms/core.py
+++ b/sdks/python/apache_beam/transforms/core.py
@@ -21,6 +21,7 @@ from __future__ import absolute_import
 
 import copy
 import inspect
+import warnings
 import types
 
 from apache_beam import pvalue
@@ -216,7 +217,7 @@ class NewDoFn(WithTypeHints, HasDisplayData):
 
 
 # TODO(Sourabh): Remove after migration to NewDoFn
-class DoFn(WithTypeHints, HasDisplayData):
+class OldDoFn(WithTypeHints, HasDisplayData):
   """A function object used by a transform with custom processing.
 
   The ParDo transform is such a transform. The ParDo.expand()
@@ -228,6 +229,10 @@ class DoFn(WithTypeHints, HasDisplayData):
   callable object using the CallableWrapperDoFn class.
   """
 
+  def __init__(self):
+    warnings.warn('Use of OldDoFn is deprecated please use DoFn instead')
+    super(OldDoFn, self).__init__()
+
   def default_label(self):
     return self.__class__.__name__
 
@@ -674,7 +679,7 @@ class ParDo(PTransformWithSideInputs):
   def __init__(self, fn_or_label, *args, **kwargs):
     super(ParDo, self).__init__(fn_or_label, *args, **kwargs)
 
-    if not isinstance(self.fn, (DoFn, NewDoFn)):
+    if not isinstance(self.fn, (OldDoFn, NewDoFn)):
       raise TypeError('ParDo must be called with a DoFn instance.')
 
   def default_type_hints(self):
@@ -685,7 +690,7 @@ class ParDo(PTransformWithSideInputs):
         self.fn.infer_output_type(input_type))
 
   def make_fn(self, fn):
-    if isinstance(fn, (DoFn, NewDoFn)):
+    if isinstance(fn, (OldDoFn, NewDoFn)):
       return fn
     return CallableWrapperDoFn(fn)
 

http://git-wip-us.apache.org/repos/asf/beam/blob/c0eef135/sdks/python/apache_beam/typehints/typecheck.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/typehints/typecheck.py 
b/sdks/python/apache_beam/typehints/typecheck.py
index 7a10a5a..bc5583f 100644
--- a/sdks/python/apache_beam/typehints/typecheck.py
+++ b/sdks/python/apache_beam/typehints/typecheck.py
@@ -23,7 +23,7 @@ import sys
 import types
 
 from apache_beam.pvalue import SideOutputValue
-from apache_beam.transforms.core import DoFn
+from apache_beam.transforms.core import OldDoFn
 from apache_beam.transforms.core import NewDoFn
 from apache_beam.transforms.window import WindowedValue
 from apache_beam.typehints import check_constraint
@@ -35,7 +35,8 @@ from apache_beam.typehints.decorators import 
_check_instance_type
 from apache_beam.typehints.decorators import getcallargs_forhints
 
 
-class TypeCheckWrapperDoFn(DoFn):
+# TODO(Sourabh): Remove after migration to NewDoFn
+class TypeCheckWrapperDoFn(OldDoFn):
   """A wrapper around a DoFn which performs type-checking of input and output.
   """
 
@@ -123,7 +124,8 @@ class TypeCheckWrapperDoFn(DoFn):
       raise TypeCheckError, error_msg, sys.exc_info()[2]
 
 
-class OutputCheckWrapperDoFn(DoFn):
+# TODO(Sourabh): Remove after migration to NewDoFn
+class OutputCheckWrapperDoFn(OldDoFn):
   """A DoFn that verifies against common errors in the output type."""
 
   def __init__(self, dofn, full_label):

Reply via email to