Skip to content

Commit

Permalink
Merge pull request #1141 from lsst/tickets/DM-48452
Browse files Browse the repository at this point in the history
DM-48452: Protect subcommand imports via entry points
  • Loading branch information
timj authored Jan 15, 2025
2 parents c03a7ff + 7ee97ef commit 36545c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ jobs:
cache: "pip"
cache-dependency-path: "setup.cfg"

- name: Install sqlite
run: sudo apt-get install sqlite libyaml-dev

- name: Install uv
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
name: isort (python)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.4
rev: v0.9.1
hooks:
- id: ruff
- repo: https://github.com/numpy/numpydoc
Expand Down
11 changes: 10 additions & 1 deletion python/lsst/daf/butler/cli/butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,16 @@ def _getPluginCommands(cls) -> defaultdict[str, list[str | PluginCommand]]:
if hasattr(cls, "entryPoint"):
plugins = entry_points(group=cls.entryPoint)
for p in plugins:
func = p.load()
try:
func = p.load()
except Exception as err:
log.warning("Could not import plugin from entry point %s, skipping.", p)
log.debug(
"Plugin import exception: %s\nTraceback:\n%s",
err,
"".join(traceback.format_tb(err.__traceback__)),
)
continue
func_name = get_full_type_name(func)
pluginCommands = {cmd.name: [PluginCommand(cmd, func_name)] for cmd in func()}
cls._mergeCommandLists(commands, defaultdict(list, pluginCommands))
Expand Down

0 comments on commit 36545c9

Please sign in to comment.