This is an automated email from the ASF dual-hosted git repository. bertty pushed a commit to branch wayang-211 in repository https://gitbox.apache.org/repos/asf/incubator-wayang.git
commit 80ff50db4104db1da31de86be19339e1aca3fa82 Author: Bertty Contreras-Rojas <[email protected]> AuthorDate: Mon Apr 11 10:45:56 2022 +0200 [WAYANG-#210] the documentation to pywy.core Signed-off-by: bertty <[email protected]> --- python/src/pywy/core/channel.py | 52 ++++++++++++++++++++++++++++++++++------ python/src/pywy/core/executor.py | 11 +++++++++ python/src/pywy/core/mapping.py | 38 +++++++++++++++++++++++++++-- python/src/pywy/core/plan.py | 31 ++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 9 deletions(-) diff --git a/python/src/pywy/core/channel.py b/python/src/pywy/core/channel.py index e6b488c4..45bd03cc 100644 --- a/python/src/pywy/core/channel.py +++ b/python/src/pywy/core/channel.py @@ -19,26 +19,64 @@ from typing import TypeVar class Channel: + """ Models the data movement between to executables :py:class:`pywy.operators.base.PywyOperator` + + Channel is the structure that is used to move the data between executables + :py:class:`pywy.operators.base.PywyOperator` and it helps to identify the + compatibility between the interaction of operators + """ def __init__(self): pass - def get_channel(self) -> 'Channel': - return self - def get_type(self): + """ return the type of the channel + + Returns + ------- + :py:class:`typing.Type` of the current Channel + """ return type(self) class ChannelDescriptor: + """ + + Attributes + ---------- + channel_type : :py:class:`typing.Type` + Type of the :py:class:`pywy.core.Channel` that the descriptor + will generate + is_reusable : bool + indicates if the source for the channel is reusable for several consumer + is_suitable_for_breakpoint : bool + indicates if the element support the breakpoint strategies + """ def __init__(self, channel_type: type, is_reusable: bool, is_suitable_for_breakpoint: bool): - self.channelType = channel_type - self.isReusable = is_reusable - self.isSuitableForBreakpoint = is_suitable_for_breakpoint + """Basic constructor of the ChannelDescriptor + + Parameters + ---------- + channel_type + Description of `channelType`. + is_reusable + Description of `is_reusable`. + is_suitable_for_breakpoint + Description of `is_suitable_for_breakpoint`. + """ + self.channel_type = channel_type + self.is_reusable = is_reusable + self.is_suitable_for_breakpoint = is_suitable_for_breakpoint def create_instance(self) -> Channel: - return self.channelType() + """Generates an instance of :py:class:`pywy.core.Channel` + + Returns + ------- + instance of :py:class:`pywy.core.Channel` + """ + return self.channel_type() CH_T = TypeVar('CH_T', bound=Channel) diff --git a/python/src/pywy/core/executor.py b/python/src/pywy/core/executor.py index a51ec564..6da77d8c 100644 --- a/python/src/pywy/core/executor.py +++ b/python/src/pywy/core/executor.py @@ -16,9 +16,20 @@ # class Executor: + """ Executor is the responsible for execute the plan + Because in each platform the execution it will be different the plan + need to be executed in the different modes, and the Executor is + the responsible for execute in the given platform + """ def __init__(self): pass def execute(self, plan): + """ execute is the method called for execute the givin plan + + Returns + ------- + does not return anything, but it will differ in some platforms + """ pass diff --git a/python/src/pywy/core/mapping.py b/python/src/pywy/core/mapping.py index a6a2f631..81a57715 100644 --- a/python/src/pywy/core/mapping.py +++ b/python/src/pywy/core/mapping.py @@ -15,20 +15,54 @@ # limitations under the License. # -from typing import Dict +from typing import Dict, Type from pywy.operators.base import PywyOperator class Mapping: - mappings: Dict[str, type] + """Mapping between :py:class:`pywy.operators.base.PywyOperator` and the executable version in a platform + + Mapping is the structure that keep the conversion between :py:class:`pywy.operators.base.PywyOperator` + and the executable version of the same operator in a different platforms + + Attributes + ---------- + mappings : :obj:`dict` + Mapping using the name as key to retrieve the executable operator + + """ + mappings: Dict[str, Type] def __init__(self): + """ + Just instance of the :obj:`dict` to store the mappings + """ self.mappings = {} def add_mapping(self, operator: PywyOperator): + """create the mapping for the instance of :py:class:`pywy.operators.base.PywyOperator` + + Parameters + ---------- + operator : :py:class:`pywy.operators.base.PywyOperator` + instance of :py:class:`pywy.operators.base.PywyOperator` that will be used to extract the + properties required to create the mapping + """ self.mappings[operator.name_basic()] = type(operator) def get_instanceof(self, operator: PywyOperator): + """Instance the executable version of :py:class:`pywy.operators.base.PywyOperator` + + Parameters + ---------- + operator : :py:class:`pywy.operators.base.PywyOperator` + instance of the :py:class:`pywy.operators.base.PywyOperator` that needs to be + converted to the executable version + Returns + ------- + executable version of :py:class:`pywy.operators.base.PywyOperator` in the + platform that the mapping is holding + """ template = self.mappings[operator.name_basic()] if template is None: raise Exception( diff --git a/python/src/pywy/core/plan.py b/python/src/pywy/core/plan.py index e08884f5..48407b98 100644 --- a/python/src/pywy/core/plan.py +++ b/python/src/pywy/core/plan.py @@ -24,14 +24,45 @@ from pywy.core.plugin import Plugin class PywyPlan: + """A PywyPlan consists of a set of :py:class:`pywy.operators.base.PywyOperator` + + the operator inside PywyPlan follow a Directed acyclic graph(DAG), and describe + how the execution needs to be performed + + Attributes + ---------- + graph : :py:class:`pywy.graph.graph.WayangGraph` + Graph that describe the DAG, and it provides the iterable properties to + the PywyPlan + plugins : :obj:`set` of :py:class:`pywy.core.plugin.Plugin` + plugins is the set of possible platforms that can be uses to execute + the PywyPlan + sinks : :py:class:`typing.Iterable` of :py:class:`pywy.operators.sink.SinkOperator` + The list of sink operators, this describe the end of the pipeline, and + they are used to build the `graph` + """ graph: WayangGraph def __init__(self, plugins: Set[Plugin], sinks: Iterable[SinkOperator]): + """basic Constructor of PywyPlan + + this constructor set the plugins and sinks element, and it prepares + everything for been executed + + Parameters + ---------- + plugins + Description of `plugins`. + sinks + Description of `sinks`. + """ self.plugins = plugins self.sinks = sinks self.set_graph() def set_graph(self): + """ it builds the :py:class:`pywy.graph.graph.WayangGraph` of the current PywyPlan + """ self.graph = WGraphOfVec(self.sinks) def print(self):
