コード例 #1
0
ファイル: simple.py プロジェクト: praveenjoshi01/forml
    def apply(self, applier: node.Worker, left: pipeline.Segment) -> pipeline.Segment:
        """Labeler composition implementation.

        Args:
            applier: Node factory to be used.
            left: Track of the left side flows.

        Returns:
            Composed segment track.
        """
        train: node.Future = node.Future()
        label: node.Future = node.Future()
        train[0].subscribe(applier[0])
        label[0].subscribe(applier[1])
        applier[0].subscribe(left.train.publisher)
        return left.use(train=left.train.extend(tail=train), label=left.train.extend(tail=label))
コード例 #2
0
ファイル: __init__.py プロジェクト: praveenjoshi01/forml
    def compose(self, left: topology.Composable) -> pipeline.Segment:
        """Compose the source segment track.

        Returns:
            Source segment track.
        """
        if not isinstance(left, topology.Origin):
            raise error.Unexpected('Source not origin')
        apply: view.Path = view.Path(node.Worker(self._apply, 0, 1))
        train: view.Path = view.Path(node.Worker(self._train, 0, 1))
        label: typing.Optional[view.Path] = None
        if self._label:
            train_tail = node.Future()
            label_tail = node.Future()
            extract = node.Worker(self._label, 1, 2)
            extract[0].subscribe(train.publisher)
            train_tail[0].subscribe(extract[0])
            label_tail[0].subscribe(extract[1])
            train = train.extend(tail=train_tail)
            label = train.extend(tail=label_tail)
        return pipeline.Segment(apply, train, label)
コード例 #3
0
        def init(
            mode: typing.Optional[typing.Union[view.Path, nodemod.Atomic]]
        ) -> view.Path:
            """Apply default cleaning to the mode segment.

            Args:
                mode: Mode segment provided either as a path or just a node.

            Returns:
                Cleaned mode path.
            """
            if not mode:
                mode = nodemod.Future()
            if isinstance(mode, nodemod.Atomic):
                mode = view.Path(mode)
            return mode
コード例 #4
0
ファイル: test_node.py プロジェクト: praveenjoshi01/forml
 def node(spec: task.Spec) -> grnode.Future:
     """Node fixture."""
     return grnode.Future()
コード例 #5
0
 def test_new(self):
     """Test segment setup."""
     assert all(
         isinstance(m, view.Path) for m in pipeline.Segment(
             view.Path(node.Future()), node.Future(), None))