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

[Enhancement] Improve registry infer_scope #334

Merged
merged 5 commits into from
Jan 31, 2023
Merged

Conversation

zhouzaida
Copy link
Collaborator

@zhouzaida zhouzaida commented Jun 23, 2022

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

resolve open-mmlab/mmcv#1116

  • Before this PR
>>> from mmengine import Registry
>>> CONVERTERS = Registry('converter')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/data/codebases/mmengine/mmengine/registry/registry.py", line 250, in __init__
    self._scope = self.infer_scope() if scope is None else scope
  File "/mnt/data/codebases/mmengine/mmengine/registry/registry.py", line 310, in infer_scope
    filename = inspect.getmodule(sys._getframe(2)).__name__  # type: ignore
AttributeError: 'NoneType' object has no attribute '__name__'
  • After this PR
>>> from mmengine import Registry
>>> CONVERTERS = Registry('converter')  # work as expected

Modification

  • Improve infer_scope at mmengine/registry/registry.py

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@zhouzaida zhouzaida changed the title Improve registry infer_scope [WIP] Improve registry infer_scope Jun 30, 2022
@ZwwWayne ZwwWayne added this to the 0.5.0 milestone Aug 15, 2022
@ZwwWayne ZwwWayne added the P2 label Aug 15, 2022
@chqirene chqirene requested a review from ZwwWayne August 25, 2022 10:15
@ZwwWayne ZwwWayne modified the milestones: 0.1.0, 0.2.0 Sep 2, 2022
@ZwwWayne ZwwWayne modified the milestones: 0.2.0, 0.3.0 Oct 24, 2022
@HAOCHENYE HAOCHENYE added the enhancement New feature or request label Oct 27, 2022
HAOCHENYE
HAOCHENYE previously approved these changes Oct 28, 2022
@zhouzaida zhouzaida changed the title [WIP] Improve registry infer_scope [Enhancement] Improve registry infer_scope Oct 31, 2022
@zhouzaida zhouzaida marked this pull request as draft November 1, 2022 06:39
@zhouzaida zhouzaida modified the milestones: 0.3.0, 0.4.0 Nov 1, 2022
@HAOCHENYE HAOCHENYE modified the milestones: 0.4.0, 0.6.0 Dec 22, 2022
@zhouzaida zhouzaida marked this pull request as ready for review January 30, 2023 07:17
@zhouzaida zhouzaida requested a review from C1rN09 as a code owner January 30, 2023 07:17
HAOCHENYE
HAOCHENYE previously approved these changes Jan 30, 2023
@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@2242fca). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #334   +/-   ##
=======================================
  Coverage        ?   78.18%           
=======================================
  Files           ?      132           
  Lines           ?     9973           
  Branches        ?     1993           
=======================================
  Hits            ?     7797           
  Misses          ?     1838           
  Partials        ?      338           
Flag Coverage Δ
unittests 78.18% <0.00%> (?)

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

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

C1rN09
C1rN09 previously approved these changes Jan 31, 2023
RangiLyu
RangiLyu previously approved these changes Jan 31, 2023
@zhouzaida zhouzaida dismissed stale reviews from RangiLyu and C1rN09 via 77ea061 January 31, 2023 11:37
@zhouzaida zhouzaida merged commit acf2160 into main Jan 31, 2023
@zhouzaida zhouzaida deleted the zzd/improve-registry branch January 31, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not create Registry instance in IPython
5 participants