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

Enhance import performance for built-in plugins #1031

Conversation

vinnamkim
Copy link
Contributor

@vinnamkim vinnamkim commented May 30, 2023

Summary

  • Ticket no. 112204
  • Apply lazy import for built-in plugins (datumaro/components/lazy_plugin.py, datumaro/plugins/specs.py)
  • Use DEFAULT_ENVIRONMENT rather than creating Environment() for CLI codes.
  • Add openvino-dev to default extra deps and update contributing.md
  • Decrease datum CLI latency by 1 sec (5 -> 4).

(before)

(datumaro) vinnamki@vinnamki:~/datumaro$ time datum -h
usage: datum [-h] [--version] [--loglevel LOGLEVEL]
...

real    0m5.052s
user    0m5.208s
sys     0m3.363s

(after)

(datumaro) vinnamki@vinnamki:~/datumaro$ time datum -h
usage: datum [-h] [--version] [--loglevel LOGLEVEL]
...

real    0m3.955s
user    0m4.323s
sys     0m3.172s

How to test

I added a test for this change.

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have added the description of my changes into CHANGELOG.​
  • I have updated the documentation accordingly

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below).
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
@vinnamkim vinnamkim added this to the 1.4.0 milestone May 30, 2023
@vinnamkim vinnamkim added the ENHANCE Enhancement of existing features label May 30, 2023
@vinnamkim vinnamkim marked this pull request as ready for review May 30, 2023 09:21
@vinnamkim vinnamkim requested review from a team as code owners May 30, 2023 09:21
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
@codecov-commenter
Copy link

codecov-commenter commented May 30, 2023

Codecov Report

Patch coverage: 80.50% and project coverage change: +0.11 🎉

Comparison is base (5f8f9a3) 78.74% compared to head (3c71796) 78.86%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1031      +/-   ##
===========================================
+ Coverage    78.74%   78.86%   +0.11%     
===========================================
  Files          237      239       +2     
  Lines        27097    27178      +81     
  Branches      5407     5418      +11     
===========================================
+ Hits         21338    21433      +95     
+ Misses        4497     4480      -17     
- Partials      1262     1265       +3     
Flag Coverage Δ
macos-11_Python-3.8 ?
ubuntu-20.04_Python-3.8 78.85% <80.50%> (+0.12%) ⬆️
windows-2019_Python-3.8 78.75% <80.50%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
datumaro/cli/commands/convert.py 20.96% <25.00%> (ø)
datumaro/cli/commands/download.py 17.85% <33.33%> (ø)
...o/cli/commands/require_project/modification/add.py 21.66% <33.33%> (ø)
...li/commands/require_project/modification/export.py 23.94% <33.33%> (ø)
...i/commands/require_project/modification/import_.py 20.89% <33.33%> (ø)
datumaro/cli/commands/transform.py 19.04% <33.33%> (ø)
datumaro/cli/commands/detect_format.py 21.42% <50.00%> (ø)
datumaro/cli/commands/merge.py 21.17% <50.00%> (ø)
datumaro/cli/commands/patch.py 26.92% <50.00%> (ø)
datumaro/cli/commands/validate.py 19.17% <50.00%> (ø)
... and 7 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

cih9088
cih9088 previously approved these changes May 31, 2023
@vinnamkim vinnamkim marked this pull request as draft May 31, 2023 01:55
@vinnamkim vinnamkim marked this pull request as ready for review May 31, 2023 07:13
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
@vinnamkim
Copy link
Contributor Author

d8f1fd0 added extra_deps mechanism to the lazy plugin import. It requires for the system who doesn't have extra deps for some plugins. Without this, that system terminates with ImportError when trying to import a lazy plugin.

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
@vinnamkim vinnamkim merged commit 4bfc505 into openvinotoolkit:develop Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENHANCE Enhancement of existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants