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

report traceback on plugin loading for certain verbosities #13846

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Apr 24, 2024

Description

Closes #13742

This is the only way I came up with. Not too clean but not horrible either, I think?

We cannot always pass exc_info because that will muddle the warnings with the traceback. Instead we only do it depending on the verbosity. With -vv (INFO) you'll get the traceback:

# conda info -vv
Error while loading conda entry point: conda-libmamba-solver (name 'AAAY' is not defined)
Traceback (most recent call last):
  File "/workspaces/conda/conda/plugins/manager.py", line 140, in load_entrypoints
    plugin = entry_point.load()
             ^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/conda/lib/python3.12/site-packages/conda_libmamba_solver/__init__.py", line 19, in <module>
    AAAY
NameError: name 'AAAY' is not defined

     active environment : base
    active env location : /opt/conda
            shell level : 1
       user config file : /root/.condarc
 populated config files : 
          conda version : 24.1.3.dev120+gbeeaa6fbd
    conda-build version : not installed
         python version : 3.12.2.final.0
                 solver : libmamba (default)
...

With -v or none:

$ conda info -v
Error while loading conda entry point: conda-libmamba-solver (name 'AAAY' is not defined)

     active environment : base
    active env location : /opt/conda
            shell level : 1
       user config file : /root/.condarc
 populated config files : 
          conda version : 24.1.3.dev120+gbeeaa6fbd
    conda-build version : not installed
         python version : 3.12.2.final.0
                 solver : libmamba (default)
...

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 24, 2024
@jaimergp jaimergp marked this pull request as ready for review April 24, 2024 17:44
@jaimergp jaimergp requested a review from a team as a code owner April 24, 2024 17:44
Copy link

codspeed-hq bot commented Apr 24, 2024

CodSpeed Performance Report

Merging #13846 will not alter performance

Comparing jaimergp:debug-plugin-loading (8768433) with main (c1af45f)

Summary

✅ 21 untouched benchmarks

jezdez
jezdez previously approved these changes Apr 24, 2024
Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

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

Needs news and a test if possible

@@ -104,7 +104,7 @@ def register(self, plugin, name: str | None = None) -> str | None:
raise PluginError(
f"Error while loading conda plugin: "
f"{name or self.get_canonical_name(plugin)} ({err})"
)
) from err
Copy link
Member

Choose a reason for hiding this comment

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

Nice, exception chaining!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Status: Approved
Development

Successfully merging this pull request may close these issues.

Plugin system: debug plugin loading errors
3 participants