示例#1
0
    def test_local_output(self):
        set_local_input_output(True)

        # Set up the function
        msg = {
            "user": "******",
            "function": "py_func",
            "py_user": "******",
            "py_func": "echo",
        }
        json_msg = dumps(msg)
        set_emulator_message(json_msg)

        # Check output is initially empty
        self.assertIsNone(get_output())

        # Set output and check
        output_a = b'12345'
        set_output(output_a)
        self.assertEqual(get_output(), output_a)

        # Set output again and check updated
        output_b = b'666777'
        set_output(output_b)
        self.assertEqual(get_output(), output_b)
示例#2
0
文件: echo.py 项目: rabbah/faasm
def faasm_main():
    i = get_input()

    print("Got input {}".format(i))

    set_output(bytes(i))

    return 0
示例#3
0
    def test_changing_function_clears_local_output(self):
        set_local_input_output(True)

        # Set output and check
        output_a = b'12345'
        set_output(output_a)
        self.assertEqual(get_output(), output_a)

        # Change function
        msg = {
            "user": "******",
            "function": "bar",
        }
        json_msg = dumps(msg)
        set_emulator_message(json_msg)

        # Check output is now empty
        self.assertIsNone(get_output())
示例#4
0
def faasm_main():
    path = get_input()

    if not path:
        print("Input must be a path")
        return 1

    path = path.decode()
    print("Path = {}, cwd = {}".format(path, os.getcwd()))

    dirlist = os.listdir(path)
    dirlist.sort()
    dir_list_str = ",".join(dirlist)

    print(dir_list_str)

    set_output(bytes(dir_list_str, "utf-8"))

    return 0
示例#5
0
文件: mat_mul.py 项目: rabbah/faasm
def divide_and_conquer():
    print("Kicking off divide and conquer")
    mat.divide_and_conquer()
    output = "Matrix multiplication finished"
    set_output(output.encode("utf-8"))
示例#6
0
文件: hello.py 项目: yifei-xue/faasm
def faasm_main():
    output = "Hello! Running Python version {}".format(sys.version)
    print(output)
    set_output(output.encode("utf-8"))