AnandInguva commented on code in PR #26795:
URL: https://github.com/apache/beam/pull/26795#discussion_r1218273827


##########
sdks/python/apache_beam/ml/transforms/tft_transforms.py:
##########
@@ -0,0 +1,301 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from typing import Any
+from typing import Dict
+from typing import List
+from typing import Optional
+
+from apache_beam.ml.transforms.base import _BaseOperation
+import tensorflow as tf
+import tensorflow_transform as tft
+from tensorflow_transform import analyzers
+from tensorflow_transform import common_types
+from tensorflow_transform import tf_utils
+
+__all__ = [
+    'compute_and_apply_vocabulary',
+    'scale_to_z_score',
+    'scale_to_0_1',
+    'apply_buckets',
+    'bucketize'
+]
+
+
+class _TFTOperation(_BaseOperation):
+  def __init__(
+      self, columns, save_result=False, output_name=None, *args, **kwargs):
+    """
+    When subclassing _TFTOperation, please make sure
+    positional arguments are part of the instance variables.
+    """
+    self.columns = columns
+    self._args = args
+    self._kwargs = kwargs
+    self.has_artifacts = False
+
+    self._save_result = save_result
+    self._output_name = output_name
+    if not columns:
+      raise RuntimeError(
+          "Columns are not specified. Please specify the column for the "
+          " op %s" % self)
+
+    if self._save_result and not self._output_name:
+      raise RuntimeError(
+          "Inplace is set to True. "
+          "but output name in which transformed data is stored"
+          " is not specified. Please specify the output name for "
+          " the op %s" % self)
+
+  def apply(self, inputs, *args, **kwargs):
+    raise NotImplementedError
+
+  def validate_args(self):
+    raise NotImplementedError
+
+  def __call__(self, data):
+    return self.apply(data, *self._args, **self._kwargs)
+
+  def get_analyzer_artifacts(self, data, col_name):

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to