Skip to content

Commit

Permalink
[WAYANG-#8] rename to pywy and organization of class
Browse files Browse the repository at this point in the history
Signed-off-by: bertty <[email protected]>
  • Loading branch information
Bertty Contreras-Rojas authored and berttty committed Apr 8, 2022
1 parent 650e127 commit 2205368
Show file tree
Hide file tree
Showing 57 changed files with 190 additions and 113 deletions.
4 changes: 4 additions & 0 deletions python/resources/test.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
la
lala
a
lalala
1 change: 0 additions & 1 deletion python/src/pywayang/__main__.py

This file was deleted.

11 changes: 0 additions & 11 deletions python/src/pywayang/platforms/python/operators/__init__.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

from .config import *
from .orchestrator import *
from .protobuf import *
from pywy.translate.protobuf import *
from .graph import *
from .test import *
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions python/src/pywayang/context.py → python/src/pywy/context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pywayang.plugin import Plugin
from pywayang.dataquanta import DataQuanta
from pywayang.operator.source import TextFileSource
from pywy.platforms.basic.plugin import Plugin
from pywy.dataquanta import DataQuanta
from pywy.wayangplan.source import TextFileSource

class WayangContext:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from pywayang.types import (GenericTco, Predicate, Function, FlatmapFunction, IterableO)
from pywayang.operator.base import (WyOperator)
from pywayang.operator.unary import (FilterOperator, MapOperator, FlatmapOperator)
from pywayang.operator.sink import TextFileSink

from pywy.types import (GenericTco, Predicate, Function, FlatmapFunction, IterableO)
from pywy.wayangplan import *

class DataQuanta(GenericTco):
"""
Expand All @@ -13,7 +10,6 @@ class DataQuanta(GenericTco):
def __init__(self, operator: WyOperator):
self.operator = operator


def filter(self: "DataQuanta[T]", p: Predicate) -> "DataQuanta[T]" :
return DataQuanta(FilterOperator(p))

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

from pywayang.graph.node import Node
from pywy.graph.node import Node
import logging


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

from pywayang.graph.visitant import Visitant
from pywy.graph.visitant import Visitant
import logging


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# limitations under the License.
#

from pywayang.orchestrator.operator import Operator
from pywayang.graph.graph import Graph
from pywayang.graph.traversal import Traversal
from pywayang.protobuf.planwriter import MessageWriter
from pywy.orchestrator.operator import Operator
from pywy.graph.graph import Graph
from pywy.graph.traversal import Traversal
from pywy.translate.protobuf.planwriter import MessageWriter
import itertools
import collections
import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#

from pywayang.orchestrator.plan import Descriptor
from pywayang.orchestrator.dataquanta import DataQuantaBuilder
from pywy.orchestrator.plan import Descriptor
from pywy.orchestrator.dataquanta import DataQuantaBuilder
import datetime


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#

from pywayang.orchestrator.plan import Descriptor
from pywayang.orchestrator.dataquanta import DataQuantaBuilder
from pywy.orchestrator.plan import Descriptor
from pywy.orchestrator.dataquanta import DataQuantaBuilder
import datetime


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import pickle
import cloudpickle
from pywayang.config.config_reader import get_source_types
from pywayang.config.config_reader import get_sink_types
from pywayang.config.config_reader import get_boundary_types
from pywy.config.config_reader import get_source_types
from pywy.config.config_reader import get_sink_types
from pywy.config.config_reader import get_boundary_types
import logging

pickle_protocol = pickle.HIGHEST_PROTOCOL
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions python/src/pywy/platforms/basic/channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Channel:

def __init__(self):
pass

def getchannel(self) -> 'Channel':
return self

def gettype(self):
return type(self)

class ChannelDescriptor:

def __init__(self, channelType: type, isReusable: bool, isSuitableForBreakpoint: bool):
self.channelType = channelType
self.isReusable = isReusable
self.isSuitableForBreakpoint = isSuitableForBreakpoint

def create_instance(self) -> Channel:
return self.channelType()
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from typing import Dict

from pywayang.operator.base import WyOperator
from pywayang.platforms.python.operators import *
from pywy.wayangplan.base import WyOperator

class Mapping:
mappings: Dict[str, type]

def __init__(self):
self.mappings = {}

def add_mapping(self, operator: PythonExecutionOperator):
def add_mapping(self, operator: WyOperator):
self.mappings[operator.name] = type(operator)

def get_instanceof(self, operator: WyOperator):
Expand All @@ -27,11 +25,4 @@ def __str__(self):
return str(self.mappings)

def __repr__(self):
return self.__str__()

OperatorMappings = Mapping()

OperatorMappings.add_mapping(PyFilterOperator())
OperatorMappings.add_mapping(PyTextFileSourceOperator())
OperatorMappings.add_mapping(PyTextFileSinkOperator())

return self.__str__()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pywayang.platform import Platform
from pywy.platforms.basic.platform import Platform
from pywy.platforms.basic.mapping import Mapping

class Plugin:
"""
Expand All @@ -10,9 +11,14 @@ class Plugin:
"""

platforms = []
mappings: Mapping

def __init__(self, *platform:Platform):
def __init__(self, *platform:Platform, mappings: Mapping = Mapping()):
self.platforms = list(platform)
self.mappings = mappings

def get_mappings(self) -> Mapping:
return self.mappings

def __str__(self):
return "Platforms: {}".format(str(self.platforms))
Expand All @@ -21,7 +27,3 @@ def __repr__(self):
return self.__str__()


# define the basic plugins that can be used
java = Plugin(Platform('java'))
spark = Plugin(Platform('spark'))
flink = Plugin(Platform('flink'))
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
from typing import ( Iterable, Callable )

class Channel:

def __init__(self):
pass

def getchannel(self) -> 'Channel':
return self

def gettype(self):
return type(self)

class ChannelDescriptor:

def __init__(self, channelType: type, isReusable: bool, isSuitableForBreakpoint: bool):
self.channelType = channelType
self.isReusable = isReusable
self.isSuitableForBreakpoint = isSuitableForBreakpoint

def create_instance(self) -> Channel:
return self.channelType()

from pywy.platforms.basic.channel import ( Channel, ChannelDescriptor )

class PyIteratorChannel(Channel):

Expand Down
10 changes: 10 additions & 0 deletions python/src/pywy/platforms/python/mappings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pywy.platforms.basic.mapping import Mapping
from pywy.platforms.python.operators import *


PywyOperatorMappings = Mapping()

PywyOperatorMappings.add_mapping(PyFilterOperator())
PywyOperatorMappings.add_mapping(PyTextFileSourceOperator())
PywyOperatorMappings.add_mapping(PyTextFileSinkOperator())

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pywayang.operator.unary import FilterOperator
from pywayang.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywayang.platforms.python.channels import (Channel, ChannelDescriptor, PyIteratorChannel,
PyIteratorChannelDescriptor, PyCallableChannelDescriptor,
PyCallableChannel)
from pywy.wayangplan.unary import FilterOperator
from pywy.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywy.platforms.python.channels import (Channel, ChannelDescriptor, PyIteratorChannel,
PyIteratorChannelDescriptor, PyCallableChannelDescriptor,
PyCallableChannel)
from typing import Set

class PyFilterOperator(FilterOperator, PythonExecutionOperator):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pywayang.operator.sink import TextFileSink
from pywayang.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywayang.platforms.python.channels import (
from pywy.wayangplan.sink import TextFileSink
from pywy.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywy.platforms.python.channels import (
Channel,
ChannelDescriptor,
PyIteratorChannel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pywayang.operator.source import TextFileSource
from pywayang.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywayang.platforms.python.channels import (
from pywy.wayangplan.source import TextFileSource
from pywy.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywy.platforms.python.channels import (
Channel,
ChannelDescriptor,
PyIteratorChannel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pywayang.operator.base import WyOperator
from pywayang.platforms.python.channels import Channel
from pywy.wayangplan.base import WyOperator
from pywy.platforms.python.channels import Channel

class PythonExecutionOperator(WyOperator):

Expand Down
11 changes: 11 additions & 0 deletions python/src/pywy/platforms/python/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pywy.platforms.python.operators.PythonExecutionOperator import PythonExecutionOperator
from pywy.platforms.python.operators.PyFilterOperator import PyFilterOperator
from pywy.platforms.python.operators.PyTextFileSourceOperator import PyTextFileSourceOperator
from pywy.platforms.python.operators.PyTextFileSinkOperator import PyTextFileSinkOperator

__ALL__ = [
PythonExecutionOperator,
PyFilterOperator,
PyTextFileSourceOperator,
PyTextFileSinkOperator
]
1 change: 1 addition & 0 deletions python/src/pywy/platforms/python/platform/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from pywy.platforms.python.platform.platform import PythonPlatform
6 changes: 6 additions & 0 deletions python/src/pywy/platforms/python/platform/platform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pywy.platforms.basic.platform import Platform

class PythonPlatform(Platform):

def __init__(self):
super(PythonPlatform, self).__init__("Python")
1 change: 1 addition & 0 deletions python/src/pywy/platforms/python/plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from pywy.platforms.python.plugin.plugin import PythonPlugin
10 changes: 10 additions & 0 deletions python/src/pywy/platforms/python/plugin/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pywy.platforms.python.platform import PythonPlatform
from pywy.platforms.basic.plugin import Plugin
from pywy.platforms.python.mappings import PywyOperatorMappings



class PythonPlugin(Plugin):

def __init__(self):
super(PythonPlugin, self).__init__(PythonPlatform(), PywyOperatorMappings)
10 changes: 10 additions & 0 deletions python/src/pywy/plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pywy.platforms.basic.platform import Platform
from pywy.platforms.basic.plugin import Plugin
from pywy.platforms.python.plugin import PythonPlugin

# define the basic plugins that can be used
java = Plugin(Platform('java'))
spark = Plugin(Platform('spark'))
flink = Plugin(Platform('flink'))
# plugin for the python platform
python = PythonPlugin()
Loading

0 comments on commit 2205368

Please sign in to comment.