Back to Serve

Debug

docs/concepts/serving/executor/hub/debug-executor.md

3.34.01.6 KB
Original Source

(debug-executor)=

Debug

{admonition}
:class: caution
This does not work for containerized Executors.

In this tutorial you will learn how to debug Hello Executor step by step.

{admonition}
:class: note

While using docarray>0.30.0, Executors do not have a fix schema and each Executor defines its own. Make sure you know
those schemas when using Executors from the Hub.

Pull the Executor

Pull the source code of the Executor you want to debug:

{tab}
```shell
jina hub pull jinaai://jina-ai/Hello
```
{tab}
```python
from jina import Executor

Executor.from_hub('jinaai://jina-ai/Hello')
```

Set breakpoints

In the ~/.jina-serve/hub-package directory there is one subdirectory for each Executor that you pulled, named by the Executor ID. You can find the Executor's source files in this directory.

Once you locate the source, you can set the breakpoints as you always do.

Debug your code

You can debug your Executor like any Python code. You can either use the Executor on its own or inside a Deployment:

{tab}
```python
from jina import Executor

exec = Executor.from_hub('jinaai://jina-ai/Hello')

# Set breakpoint as needed
exec.foo()
```
{tab}
```python
from jina import Deployment
from docarray.documents.legacy import LegacyDocument

dep = Deployment(uses='jinaai://jina-ai/Hello')

with dep:
    res = dep.post('/', inputs=LegacyDocument(text='hello'), return_results=True)
    print(res)
```