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

feat(types): make apply and apply_batch self-returning #4018

Merged
merged 1 commit into from
Dec 2, 2021

Conversation

hanxiao
Copy link
Member

@hanxiao hanxiao commented Dec 2, 2021

import onnxruntime

model = onnxruntime.InferenceSession('resnet.onnx')

from jina import DocumentArray, Document


def pre_proc(d: Document):
    return (
        d.load_uri_to_image_blob()
        .set_image_blob_shape((224, 224))
        .set_image_blob_normalization()
        .set_image_blob_channel_axis(-1, 0)
    )


def post_proc(d: Document):
    return d.set_image_blob_channel_axis(0, -1).set_image_blob_inv_normalization()


def embed(da):
    return da.embed(model)


(
    DocumentArray.from_files('/Users/hanxiao/Downloads/left/*.jpg')[:1000]
    .apply(pre_proc)
    .apply_batch(embed, batch_size=16)
    .apply(post_proc)
    .plot_embeddings(image_sprites=True)
)

@github-actions github-actions bot added size/S area/core This issue/PR affects the core codebase component/type labels Dec 2, 2021
@github-actions
Copy link

github-actions bot commented Dec 2, 2021

Latency summary

Current PR yields:

  • 😶 index QPS at 1270, delta to last 2 avg.: -4%
  • 🐢🐢 query QPS at 24, delta to last 2 avg.: -12%
  • 🐢🐢 dam extend QPS at 35472, delta to last 2 avg.: -15%
  • 🐢🐢 avg flow time within 1.5315 seconds, delta to last 2 avg.: +6%
  • 😶 import jina within 0.4353 seconds, delta to last 2 avg.: +2%

Breakdown

Version Index QPS Query QPS DAM Extend QPS Avg Flow Time (s) Import Time (s)
current 1270 24 35472 1.5315 0.4353
2.5.1 1529 33 51651 1.283 0.3385
2.5.0 1134 20 32393 1.5857 0.509

Backed by latency-tracking. Further commits will update this comment.

@codecov
Copy link

codecov bot commented Dec 2, 2021

Codecov Report

Merging #4018 (750e3f0) into master (e5326e6) will decrease coverage by 4.10%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4018      +/-   ##
==========================================
- Coverage   79.46%   75.35%   -4.11%     
==========================================
  Files         183      183              
  Lines       12926    12934       +8     
==========================================
- Hits        10272     9747     -525     
- Misses       2654     3187     +533     
Flag Coverage Δ
daemon 43.25% <28.57%> (-0.02%) ⬇️
jina 75.16% <28.57%> (-1.13%) ⬇️

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

Impacted Files Coverage Δ
jina/types/arrays/mixins/embed.py 14.92% <0.00%> (-0.23%) ⬇️
jina/types/arrays/mixins/parallel.py 30.95% <22.22%> (-1.49%) ⬇️
jina/types/document/mixins/sugar.py 39.13% <33.33%> (-3.73%) ⬇️
jina/__init__.py 70.23% <100.00%> (ø)
jina/peapods/pods/k8slib/kubernetes_deployment.py 20.00% <0.00%> (-74.67%) ⬇️
jina/peapods/pods/k8slib/kubernetes_tools.py 20.22% <0.00%> (-64.05%) ⬇️
jina/parsers/deprecated.py 33.33% <0.00%> (-50.01%) ⬇️
jina/peapods/pods/k8slib/kubernetes_client.py 20.58% <0.00%> (-50.00%) ⬇️
jina/peapods/pods/k8s.py 33.05% <0.00%> (-46.78%) ⬇️
jina/types/document/generators.py 48.18% <0.00%> (-40.91%) ⬇️
... and 29 more

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 b039379...750e3f0. Read the comment docs.

@hanxiao hanxiao merged commit 6ad6b8d into master Dec 2, 2021
@hanxiao hanxiao deleted the feat-apply-return-self branch December 2, 2021 15:12
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 component/type size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant