Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function output pipe into next function #150

Open
heavenlxj opened this issue Apr 1, 2022 · 2 comments
Open

Function output pipe into next function #150

heavenlxj opened this issue Apr 1, 2022 · 2 comments

Comments

@heavenlxj
Copy link

heavenlxj commented Apr 1, 2022

i am confusing how to use the output in the function
e.g. i have the 1st function like that:

def handle(req):
    """handle a request to the function
    Args:
        req (str): request body
    """
    print("This is the 1st Python API")
    return 1

and the 2nd function like this:

def handle(req):
    """handle a request to the function
    Args:
        req (str): request body
    """
    print("This is the Second Python API")
    print("Req is", req)
    a = int(req)
    b = a+1
    print("b is ",b)
    return b

Actually, i assume use the 1st function output in the 2nd function, if 1st ret 1, the 2nd will accept the output and make a is 1, then b=2 and return 2.

The flow code here:

func Define(flow *faasflow.Workflow, context *faasflow.Context) (err error) {
	flow.SyncNode().
		Apply("pytest1").
		Apply("pytest2").
		Modify(func(data []byte) ([]byte, error) {
			// do something
			fmt.Print(data)
			return data, nil
		})
	return nil
}

But when i invoke the flow function, it will throw the exception:

Internal Server Error
[ Failed ] request failed to be processed. error: failed to execute request. Node(0_1_sync), Operation (pytest2), error: execution failed, Function(pytest2), error: function execution failed, invalid return status 500 while connecting http://gateway.openfaas:8080/function/pytest2

seems the 2nd function input req is None make the error.
So what is the right way for this situation, for result pass? thanks for your help

may be the usage is wrong, i assume the intermediate date could store the output like context, so how to share the context between these functions?

or if i can set the context= { "result": "1st function output" }, then could use this context in the 2nd function, is it possible support?

@TYsonHe
Copy link

TYsonHe commented Aug 14, 2023

oh,I have the same question,do you solve this problem?
can you teach me please?

@TYsonHe
Copy link

TYsonHe commented Aug 14, 2023

@s8sg

oh,I have the same question,do you solve this problem? can you teach me please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants