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

Plugin system: debug plugin loading errors #13742

Open
2 tasks done
jaimergp opened this issue Mar 28, 2024 · 0 comments · May be fixed by #13846
Open
2 tasks done

Plugin system: debug plugin loading errors #13742

jaimergp opened this issue Mar 28, 2024 · 0 comments · May be fixed by #13846
Labels
plugins pertains to a plugin/subcommand source::contributor created by a frequent contributor type::feature request for a new feature or capability

Comments

@jaimergp
Copy link
Contributor

Checklist

  • I added a descriptive title
  • I searched open requests and couldn't find a duplicate

What is the idea?

When a plugin cannot be loaded, conda will print a short message with the exception. I suggest we also print the traceback when verbose or debug modes are enabled.

Why is this needed?

To better debug why a plugin cannot be loaded, and where the exception is being raised.

What should happen?

If I do conda info with a broken conda-libmamba-solver (e.g. I'm developing something), I get this:

Error while loading conda entry point: conda-libmamba-solver (cannot import name 'QueryResult' from 'libmambapy' (/opt/conda/lib/python3.11/site-packages/libmambapy/__init__.py))

I would like to have conda info --debug print this instead:

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.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspaces/conda-libmamba-solver/conda_libmamba_solver/plugin.py", line 6, in <module>
    from .repoquery import configure_parser, repoquery
  File "/workspaces/conda-libmamba-solver/conda_libmamba_solver/repoquery.py", line 19, in <module>
    from .index2 import LibMambaIndexHelper
  File "/workspaces/conda-libmamba-solver/conda_libmamba_solver/index2.py", line 97, in <module>
    from libmambapy import QueryResult, Query, ChannelContext, Context
ImportError: cannot import name 'QueryResult' from 'libmambapy' (/opt/conda/lib/python3.11/site-packages/libmambapy/__init__.py)
Error while loading conda entry point: conda-libmamba-solver (cannot import name 'QueryResult' from 'libmambapy' (/opt/conda/lib/python3.11/site-packages/libmambapy/__init__.py))

Additional Context

The current code base has this comment but I think it can actually work:

  # attempt to load plugin from entry point
  try:
      plugin = entry_point.load()
  except Exception as err:
      # not using exc_info=True here since the CLI loggers are
      # set up after CLI initialization and argument parsing,
      # meaning that it comes too late to properly render
      # a traceback
+     kwargs = {"exc_info": err} if context.debug else {}
      log.warning(
          f"Error while loading conda entry point: {entry_point.name} ({err})",
+         **kwargs
      )
      continue
@jaimergp jaimergp added the type::feature request for a new feature or capability label Mar 28, 2024
@travishathaway travishathaway added the source::contributor created by a frequent contributor label Mar 28, 2024
@jaimergp jaimergp added the plugins pertains to a plugin/subcommand label Apr 15, 2024
@jaimergp jaimergp linked a pull request Apr 24, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugins pertains to a plugin/subcommand source::contributor created by a frequent contributor type::feature request for a new feature or capability
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

2 participants