Invocation state proxy for Function Executors and new API for functions #1134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We don't want to have Indexify Server API credentials in Function Executors because it's a security risk if Function Executors run not trusted code. To achieve that Executor provides a gRPC API to Function Executor to get/set graph invocation state. Once a request is recieved Executor finds invocation ID of the requesting Function Executor and does Indexify Server API call to get/set and invocation state key.
There are a few customer function facing API changes here:
Instead of calling
get_ctx().set_state_key()
andget_ctx().get_state_key()
they callget_ctx().invocation_state.get()
andget_ctx().invocation_state.set()
.This intoduces a separate API for graph invocation state which is more clear than adding unbounded number of methods into GraphInvocationContext object returned by
get_ctx()
. We're thinking about long term extensibility of it here. Also as local graph uses LocalInvocationState implementation and remote graph is using ProxiedInvocationState we'll just need to forwardget_ctx().set_state_key()
andget_ctx().get_state_key()
calls into these implementations anyway.Another change is that
set(key, value)
now accepts any value that is serializable using CloudPickle. This is provides a consisten "no surprises" UX because we're using CloudPickle for function inputs and outputs. Supporting this required small changes on Indexify Server side as previous JSON was explicitly used at HTTP protocol and storage layers. Now it supports arbitrary binary and textual formats for invocation state values.Finally
get(key)
now returns Optional[Any] so None is returned if the key wasn't set yet. This allows the customer code to decide what to do in this case.Testing:
make fmt
make test
Contribution Checklist
make fmt
inpython-sdk/
.make fmt
inserver/
.