Пример #1
0
from numap import NuMap
from papy.core import Dagger, Piper


def l33t(inbox):
    word = inbox[0]
    return word.replace('e', '3').replace('o', '0')


def l33ter(inbox):
    word = inbox[0]
    return word.replace('l', '1')


# execution endgine
numap = NuMap()

# function nodes
l33t_piper = Piper(l33t, parallel=numap)
l33ter_piper = Piper(l33ter, parallel=numap)

# topology
pipeline = Dagger()
pipeline.add_pipe((l33t_piper, l33ter_piper))
end = pipeline.get_outputs()[0]

# runtime
pipeline.connect([['hello', 'world']])
pipeline.start()
print list(end)
Пример #2
0
        ("package", "txt"),
    ),
    "params":{
    }
}

sh_worker = Worker(script, (sh_cfg,))
py_worker = Worker(script, (py_cfg,))

# execution engine
numap = NuMap()

# function nodes
sh_piper = Piper(sh_worker, parallel=numap)
py_piper = Piper(py_worker, parallel=numap)

# topology
pipeline = Dagger()
pipeline.add_pipe((sh_piper, py_worker))
end = pipeline.get_outputs()[0]

# runtime
pipeline.connect(
    [[
        {"message":"work_moar.txt"}, 
        {"message":"nevar_give_up.txt"}
    ]])

pipeline.start()
print list(end)
Пример #3
0
# -*- coding: utf-8 -*-
from numap import NuMap
from papy.core import Dagger, Piper

def l33t(inbox):
    word = inbox[0]
    return word.replace('e', '3').replace('o', '0')

def l33ter(inbox):
    word = inbox[0]
    return word.replace('l', '1')

# execution endgine
numap = NuMap()

# function nodes
l33t_piper = Piper(l33t, parallel=numap)
l33ter_piper = Piper(l33ter, parallel=numap)

# topology
pipeline = Dagger()
pipeline.add_pipe((l33t_piper, l33ter_piper))
end = pipeline.get_outputs()[0]

# runtime
pipeline.connect([['hello', 'world']])
pipeline.start()
print list(end)


Пример #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from papy.core import Piper, Dagger


def l33t(inbox):
    word = inbox[0]
    return word.replace("e", "3").replace("o", "0")


def join(inbox):
    left_word, right_word = inbox
    return left_word + " " + right_word


left_l33t = Piper(l33t, branch=1)
right_l33t = Piper(l33t, branch=2)
join_l33t = Piper(join)

pipeline = Dagger()
pipeline.add_pipe((left_l33t, join_l33t))
pipeline.add_pipe((right_l33t, join_l33t))
end = pipeline.get_outputs()[0]

pipeline.connect([["hello", "hi"], ["world", "folks"]])
pipeline.start()
print list(end)
Пример #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from papy.core import Piper, Dagger

def l33t(inbox):
    word = inbox[0]
    return word.replace('e', '3').replace('o', '0')

def join(inbox):
    left_word, right_word = inbox
    return left_word + " " + right_word

left_l33t = Piper(l33t, branch=1)
right_l33t = Piper(l33t, branch=2)
join_l33t = Piper(join)

pipeline = Dagger()
pipeline.add_pipe((left_l33t, join_l33t))
pipeline.add_pipe((right_l33t, join_l33t))
end = pipeline.get_outputs()[0]

pipeline.connect([
                  ['hello', 'hi'],
                  ['world', 'folks']
                  ])
pipeline.start()
print list(end)


Пример #6
0
    "script": "python_script.py",
    "in": ("greeting", ),
    "out": (("package", "txt"), ),
    "params": {}
}

sh_worker = Worker(script, (sh_cfg, ))
py_worker = Worker(script, (py_cfg, ))

# execution engine
numap = NuMap()

# function nodes
sh_piper = Piper(sh_worker, parallel=numap)
py_piper = Piper(py_worker, parallel=numap)

# topology
pipeline = Dagger()
pipeline.add_pipe((sh_piper, py_worker))
end = pipeline.get_outputs()[0]

# runtime
pipeline.connect([[{
    "message": "work_moar.txt"
}, {
    "message": "nevar_give_up.txt"
}]])

pipeline.start()
print list(end)
Пример #7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from numap import NuMap
from papy.core import Dagger, Piper
from papy.util.func import ipasser


def merge(inbox):
    word1 = inbox[0]
    word2 = inbox[1]
    return word1 + word2


# function nodes
merge_p = Piper(merge)

inp1_p = Piper(ipasser)
inp2_p = Piper(ipasser)

# topology
pipeline = Dagger()
pipeline.add_pipe((inp2_p, merge_p), branch="2")
pipeline.add_pipe((inp1_p, merge_p), branch="1")

end = pipeline.get_outputs()[0]
# # runtime
pipeline.connect([['hello ', 'world '], ["world", "hello"]])
pipeline.start()
print list(end)
Пример #8
0

def upper(inbox):
    word = inbox[0]
    return word.upper()


def E_to_3(inbox):
    word = inbox[0]
    return word.replace('E', '3')


def O_to_0(inbox):
    word = inbox[0]
    return word.replace('O', '0')


upper_fork = Piper(upper)
E_end = Piper(E_to_3, branch=1)
O_end = Piper(O_to_0, branch=2)

pipeline = Dagger()
pipeline.add_pipe((upper_fork, E_end))
pipeline.add_pipe((upper_fork, O_end))

left_end, right_end = pipeline.get_outputs()

pipeline.connect([['hello', 'world']])
pipeline.start()
print zip(left_end, right_end)
Пример #9
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from numap import NuMap
from papy.core import Dagger, Piper
from papy.util.func import ipasser

def merge(inbox):
    word1 = inbox[0]
    word2 = inbox[1]
    return word1 + word2

# function nodes
merge_p = Piper(merge)

inp1_p = Piper(ipasser)
inp2_p = Piper(ipasser)

# topology
pipeline = Dagger()
pipeline.add_pipe((inp2_p, merge_p), branch="2")
pipeline.add_pipe((inp1_p, merge_p), branch="1")

end = pipeline.get_outputs()[0]
# # runtime
pipeline.connect([['hello ', 'world '], ["world", "hello"]])
pipeline.start()
print list(end)


Пример #10
0
from papy.core import Piper, Dagger

def upper(inbox):
    word = inbox[0]
    return word.upper()

def E_to_3(inbox):
    word = inbox[0]
    return word.replace('E', '3')

def O_to_0(inbox):
    word = inbox[0]
    return word.replace('O', '0')

upper_fork = Piper(upper)
E_end = Piper(E_to_3, branch=1)
O_end = Piper(O_to_0, branch=2)

pipeline = Dagger()
pipeline.add_pipe((upper_fork, E_end))
pipeline.add_pipe((upper_fork, O_end))

left_end, right_end = pipeline.get_outputs()

pipeline.connect([['hello', 'world']])
pipeline.start()
print zip(left_end, right_end)