Skip to content

Commit

Permalink
perf: cache entry points (#10889)
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com>
  • Loading branch information
NickCrews and cpcloud authored Feb 24, 2025
1 parent 40b20f1 commit 62e9bca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
21 changes: 4 additions & 17 deletions ibis/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import subprocess
import sys
from importlib.metadata import EntryPoint
from typing import NamedTuple

import pytest
from pytest import param
Expand Down Expand Up @@ -37,24 +36,12 @@ def test_missing_backend():


def test_multiple_backends(mocker):
class Distribution(NamedTuple):
entry_points: list[EntryPoint]

entrypoints = [
EntryPoint(
name="foo",
value="ibis.backends.backend1",
group="ibis.backends",
),
EntryPoint(
name="foo",
value="ibis.backends.backend2",
group="ibis.backends",
),
return_value = [
EntryPoint(name="foo", value="ibis.backends.backend1", group="ibis.backends"),
EntryPoint(name="foo", value="ibis.backends.backend2", group="ibis.backends"),
]
return_value = entrypoints

mocker.patch("importlib.metadata.entry_points", return_value=return_value)
mocker.patch("ibis.util.backend_entry_points", return_value=return_value)

msg = r"\d+ packages found for backend 'foo'"
with pytest.raises(RuntimeError, match=msg):
Expand Down
1 change: 1 addition & 0 deletions ibis/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def experimental(func):
return func


@functools.cache
def backend_entry_points() -> list[importlib.metadata.EntryPoint]:
"""Get the list of installed `ibis.backend` entrypoints."""

Expand Down

0 comments on commit 62e9bca

Please sign in to comment.