docs/concepts/serving/executor/index.md
(executor-cookbook)=
An {class}~jina.Executor is a self-contained service that performs a task on Documents.
You can create an Executor by extending the Executor class and adding logic to endpoint methods.
Once you've learned about Documents and DocList from docarray, you can use all its power and expressiveness to build a multimodal application.
But what if you want to go bigger? Organize your code into modules, serve and scale them? That's where Executors come in.
jina hub push/pull.~jina.Deployment.~jina.Flow.from jina import Executor, requests, Deployment
from docarray import DocList
from docarray.documents import TextDoc
class MyExecutor(Executor):
@requests
def foo(self, docs: DocList[TextDoc], **kwargs) -> DocList[TextDoc]:
for d in docs:
d.text = 'hello world'
return docs
with Deployment(uses=MyExecutor) as dep:
response_docs = dep.post(on='/', inputs=DocList[TextDoc]([TextDoc(text='hello')]), return_type=DocList[TextDoc])
print(f'Text: {response_docs[0].text}')
─────────────────────── 🎉 Deployment is ready to serve! ───────────────────────
╭────────────── 🔗 Endpoint ───────────────╮
│ ⛓ Protocol GRPC │
│ 🏠 Local 0.0.0.0:55581 │
│ 🔒 Private 192.168.0.5:55581 │
│ 🌍 Public 158.181.77.236:55581 │
╰──────────────────────────────────────────╯
Text: hello world
:hidden:
basics
create
add-endpoints
serve
dynamic-batching
health-check
hot-reload
file-structure
containerize
instrumentation
yaml-spec