This is an automated email from the ASF dual-hosted git repository.

bertty pushed a commit to branch python-platform
in repository https://gitbox.apache.org/repos/asf/incubator-wayang.git

commit 2443b37e0d9c3b6d5b247ddf3f2e8da9a1adf9b1
Author: Bertty Contreras-Rojas <[email protected]>
AuthorDate: Wed Apr 6 17:09:50 2022 +0200

    [WAYANG-#8] Add prefix and postfix to the name at creation time
    
    Signed-off-by: bertty <[email protected]>
---
 .../pywy/platforms/python/operators/PythonExecutionOperator.py   | 3 +++
 python/src/pywy/wayangplan/base.py                               | 8 +++++++-
 python/src/pywy/wayangplan/sink.py                               | 6 ++++--
 python/src/pywy/wayangplan/source.py                             | 5 ++++-
 python/src/pywy/wayangplan/unary.py                              | 9 ++++++---
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git 
a/python/src/pywy/platforms/python/operators/PythonExecutionOperator.py 
b/python/src/pywy/platforms/python/operators/PythonExecutionOperator.py
index 5dd5f7f7..52a82944 100644
--- a/python/src/pywy/platforms/python/operators/PythonExecutionOperator.py
+++ b/python/src/pywy/platforms/python/operators/PythonExecutionOperator.py
@@ -3,5 +3,8 @@ from pywy.platforms.python.channels import Channel
 
 class PythonExecutionOperator(WyOperator):
 
+    def prefix(self) -> str:
+        return 'Py'
+
     def execute(self, inputs: Channel, output: Channel):
         pass
\ No newline at end of file
diff --git a/python/src/pywy/wayangplan/base.py 
b/python/src/pywy/wayangplan/base.py
index 61a4a5dc..a87a2f6a 100644
--- a/python/src/pywy/wayangplan/base.py
+++ b/python/src/pywy/wayangplan/base.py
@@ -19,7 +19,7 @@ class WyOperator:
                  input_lenght: Optional[int] = 1,
                  output_lenght: Optional[int] = 1
     ):
-        self.name = name
+        self.name = (self.prefix() + name + self.postfix()).strip()
         self.inputSlot = input
         self.inputs = input_lenght
         self.outputSlot = output
@@ -57,6 +57,12 @@ class WyOperator:
     def get_output_channeldescriptors(self) -> Set[ChannelDescriptor]:
         pass
 
+    def prefix(self) -> str:
+        return ''
+
+    def postfix(self) -> str:
+        return ''
+
     def __str__(self):
         return "BaseOperator: \n\t- name: {}\n\t- inputs: {} {}\n\t- outputs: 
{} {} \n".format(
             str(self.name),
diff --git a/python/src/pywy/wayangplan/sink.py 
b/python/src/pywy/wayangplan/sink.py
index 01cb0e9e..2d832099 100644
--- a/python/src/pywy/wayangplan/sink.py
+++ b/python/src/pywy/wayangplan/sink.py
@@ -4,7 +4,9 @@ from pywy.types import GenericTco
 from pywy.wayangplan.base import WyOperator
 
 class SinkOperator(WyOperator):
-    pass
+
+    def postfix(self) -> str:
+        return 'Sink'
 
 class SinkUnaryOperator(SinkOperator):
 
@@ -24,7 +26,7 @@ class TextFileSink(SinkUnaryOperator):
     path: str
 
     def __init__(self, path: str):
-        super().__init__('TextFileSink')
+        super().__init__('TextFile')
         self.path = path
 
     def __str__(self):
diff --git a/python/src/pywy/wayangplan/source.py 
b/python/src/pywy/wayangplan/source.py
index 7428b904..202a4655 100644
--- a/python/src/pywy/wayangplan/source.py
+++ b/python/src/pywy/wayangplan/source.py
@@ -11,6 +11,9 @@ class SourceUnaryOperator(WyOperator):
             output_lenght = 1
         )
 
+    def postfix(self) -> str:
+        return 'Source'
+
     def __str__(self):
         return super().__str__()
 
@@ -24,7 +27,7 @@ class TextFileSource(SourceUnaryOperator):
     path: str
 
     def __init__(self, path: str):
-        super(TextFileSource, self).__init__('TextFileSource')
+        super(TextFileSource, self).__init__('TextFile')
         self.path = path
 
     def __str__(self):
diff --git a/python/src/pywy/wayangplan/unary.py 
b/python/src/pywy/wayangplan/unary.py
index a43b4c25..26c28402 100644
--- a/python/src/pywy/wayangplan/unary.py
+++ b/python/src/pywy/wayangplan/unary.py
@@ -17,6 +17,9 @@ class UnaryToUnaryOperator(WyOperator):
     def __init__(self, name:str, input:GenericTco, output:GenericUco):
         super().__init__(name, input, output, 1, 1)
 
+    def postfix(self) -> str:
+        return 'OperatorUnary'
+
     def __str__(self):
         return super().__str__()
 
@@ -31,7 +34,7 @@ class FilterOperator(UnaryToUnaryOperator):
 
     def __init__(self, predicate: Predicate):
         type = getTypePredicate(predicate) if predicate else None
-        super().__init__("FilterOperator", type, type)
+        super().__init__("Filter", type, type)
         self.predicate = predicate
 
     def __str__(self):
@@ -46,7 +49,7 @@ class MapOperator(UnaryToUnaryOperator):
 
     def __init__(self, function: Function):
         types = getTypeFunction(function) if function else (None, None)
-        super().__init__("MapOperator", types[0], types[1])
+        super().__init__("Map", types[0], types[1])
         self.function = function
 
     def getWrapper(self):
@@ -68,7 +71,7 @@ class FlatmapOperator(UnaryToUnaryOperator):
 
     def __init__(self, fmfunction: FlatmapFunction):
         types = getTypeFlatmapFunction(fmfunction) if fmfunction else (None, 
None)
-        super().__init__("FlatmapOperator", types[0], types[1])
+        super().__init__("Flatmap", types[0], types[1])
         self.fmfunction = fmfunction
 
     def getWrapper(self):

Reply via email to