8000 feat: custom monitoring with context manager by samsja · Pull Request #4892 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: custom monitoring with context manager #4892

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

Merged
merged 4 commits into from
Jun 7, 2022

Conversation

samsja
Copy link
Contributor
@samsja samsja commented Jun 7, 2022

Custom monitoring with context manager

Context

having only the possibility to monitor custom part of Executor with a decorator is a limitation. We need to have a context manager as well. See full issue here : #4876

What this PR do

This pr allow developer of Executor to use custom metrics with a context manager

example:

from jina import requests, Executor
from docarray import DocumentArray

def preprocessing(self, docs: DocumentArray):
    ...

def model_inference(self, tensor):
    ...

class MyExecutor(Executor):

    @requests
    def encode(self, docs: DocumentArray, **kwargs):
        with self.monitor('preprocessing_seconds', 'Time preprocessing the requests'):
            docs.tensors = preprocessing(docs)
        with self.monitor('model_inference_seconds', 'Time doing inference the requests'):
            docs.embedding = model_inference(docs.tensors)

@samsja samsja linked an issue Jun 7, 2022 that may be closed by this pull request
@samsja samsja changed the title Feat custom monitoring cm feat: custom monitoring with context manager Jun 7, 2022
@github-actions github-actions bot added size/M area/core This issue/PR affects the core codebase area/docs This issue/PR affects the docs area/testing This issue/PR affects testing labels Jun 7, 2022
@codecov
Copy link
codecov bot commented Jun 7, 2022

Codecov Report

Merging #4892 (ee58457) into master (abe735f) will decrease coverage by 0.04%.
The diff coverage is 90.00%.

@@            Coverage Diff             @@
##           master    #4892      +/-   ##
==========================================
- Coverage   88.18%   88.13%   -0.05%     
==========================================
  Files         110      110              
  Lines        8481     8480       -1     
==========================================
- Hits         7479     7474       -5     
- Misses       1002     1006       +4     
Flag Coverage Δ
jina 88.13% <90.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jina/serve/runtimes/base.py 74.19% <ø> (ø)
jina/serve/executors/__init__.py 86.62% <66.66%> (ø)
jina/hubble/hubio.py 86.41% <93.75%> (+0.07%) ⬆️
jina/serve/executors/decorators.py 97.91% <100.00%> (+0.94%) ⬆️
jina/serve/runtimes/gateway/http/__init__.py 98.03% <0.00%> (-1.97%) ⬇️
...a/orchestrate/deployments/config/docker_compose.py 99.00% <0.00%> (-1.00%) ⬇️
jina/orchestrate/flow/base.py 89.45% <0.00%> (-0.58%) ⬇️
jina/orchestrate/deployments/config/helper.py 98.24% <0.00%> (+3.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d8aa64...ee58457. Read the comment docs.

JoanFM
JoanFM previously approved these changes Jun 7, 2022
Copy link
Contributor
@JoanFM JoanFM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a typo, if u want to change everywhere

@github-actions
Copy link
github-actions bot commented Jun 7, 2022

📝 Docs are deployed on https://feat-custom-monitoring-cm--jina-docs.netlify.app 🎉

@hanxiao
Copy link
Member
hanxiao commented Jun 7, 2022

btw are we sure monitor is the right terminology?

@JoanFM JoanFM merged commit 6fa5342 into master Jun 7, 2022
@JoanFM JoanFM deleted the feat-custom-monitoring-cm branch June 7, 2022 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core This issue/PR affects the core codebase area/docs This issue/PR affects the docs area/testing This issue/PR affects testing size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the monitor decorator a context manager as well
3 participants
0