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

load CocoPageMapper once per process #1184

Conversation

jihyeonyi
Copy link

@jihyeonyi jihyeonyi commented Oct 24, 2023

Summary

When loading CocoPageMapper multiple times per interpreter or process, it would raise an ImportError as shown below.

image

So, I have modified it to import the module only once.

How to test

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

@jihyeonyi jihyeonyi marked this pull request as ready for review October 24, 2023 07:22
@jihyeonyi jihyeonyi requested review from a team as code owners October 24, 2023 07:22
@jihyeonyi jihyeonyi requested review from wonjuleee and removed request for a team October 24, 2023 07:22
Comment on lines +8 to +11
try:
from datumaro.rust_api import CocoPageMapper as CocoPageMapperImpl
except ImportError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the exact case requiring this fix? If any interpreter goes into L10-11, it means that it doesn't loads CocoPageMapperImpl just a once but does not load CocoPageMapperImpl totally.

Copy link
Author

Choose a reason for hiding this comment

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

The error occurs when importing a dataset multiple times in the streamlit GUI.
I thought this problem can be reproduced easily in the normal interpreter, but it was not.
I guess I need to handle this problem in another way.
So, I'll cancel this change at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

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

What Python version is in your dev env? 3.12?

Copy link
Author

Choose a reason for hiding this comment

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

My Python version is 3.10.
Anyway, it's strange that I cannot reproduce this problem after reverting the code.
I'll revisit this issue once it is reproduced.
I might have made a mistake when dealing with the streamlit.

@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (19fb861) 79.96% compared to head (303aaef) 79.96%.

Additional details and impacted files
@@                Coverage Diff                 @@
##           releases/1.5.0    #1184      +/-   ##
==================================================
- Coverage           79.96%   79.96%   -0.01%     
==================================================
  Files                 265      265              
  Lines               29705    29708       +3     
  Branches             5831     5831              
==================================================
+ Hits                23755    23756       +1     
- Misses               4618     4620       +2     
  Partials             1332     1332              
Flag Coverage Δ
macos-11_Python-3.8 79.08% <50.00%> (-0.01%) ⬇️
ubuntu-20.04_Python-3.8 79.96% <50.00%> (-0.01%) ⬇️
windows-2022_Python-3.8 79.93% <50.00%> (-0.01%) ⬇️

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

Files Coverage Δ
.../datumaro/plugins/data_formats/coco/page_mapper.py 78.37% <50.00%> (-3.98%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jihyeonyi jihyeonyi closed this Oct 24, 2023
@jihyeonyi jihyeonyi deleted the jihyeony/load_coco_page_mapper_once branch October 24, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants