Skip to content

Commit

Permalink
add xfailing install tests back
Browse files Browse the repository at this point in the history
  • Loading branch information
khiron committed Apr 8, 2024
1 parent d821568 commit 810433f
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 191 deletions.
26 changes: 20 additions & 6 deletions src/cogent3/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
import warnings

import stevedore
import stevedore._cache

from cogent3.util.table import Table

from .composable import is_app, is_app_composable
from .io import open_data_store


# Entry_point for apps to register themselves as plugins
APP_ENTRY_POINT = "cogent3.app"


def _get_extension_attr(extension):
"""
This function returns app details for display.
Expand Down Expand Up @@ -69,14 +72,23 @@ def get_app_manager(force: bool = False) -> stevedore.ExtensionManager:
"""
global __apps
if force:
importlib.invalidate_caches()
stevedore.extension.ExtensionManager.ENTRY_POINT_CACHE.get
if APP_ENTRY_POINT in stevedore.extension.ExtensionManager.ENTRY_POINT_CACHE:
del stevedore.extension.ExtensionManager.ENTRY_POINT_CACHE[APP_ENTRY_POINT]
if not __apps or force:
__apps = None # in some cases setting to None does not reset the global __apps, but creating a new ExtensionManager does
__apps = stevedore.ExtensionManager(
namespace=APP_ENTRY_POINT, invoke_on_load=False
)
importlib.invalidate_caches() # reset the cache of entry points
cache = __apps.ENTRY_POINT_CACHE
# technique for clearing cache from https://github.com/openstack/cloudkitty/blob/e552c3851fa4bb98096228a89613ceb823d45e72/cloudkitty/utils.py#L198
if APP_ENTRY_POINT in cache:
del cache[APP_ENTRY_POINT]
else:
cache.clear()

if not __apps:
__apps = stevedore.ExtensionManager(
namespace=APP_ENTRY_POINT, invoke_on_load=False
)

return __apps


Expand Down Expand Up @@ -178,7 +190,9 @@ def _get_app_matching_name(name: str):
else:
modname = None

extensions_matching = [extension for extension in get_app_manager() if extension.name == name]
extensions_matching = [
extension for extension in get_app_manager() if extension.name == name
]
if not extensions_matching:
raise ValueError(f"App {name!r} not found. Please check for typos.")

Expand Down
1 change: 1 addition & 0 deletions tests/test_app/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_app_help(capsys):
assert "Options" in got
assert got.count("bytes") >= 2 # both input and output types are bytes


@pytest.mark.parametrize(
"app_name", ("bootstrap", "from_primitive", "load_db", "take_named_seqs")[:1]
)
Expand Down
Loading

0 comments on commit 810433f

Please sign in to comment.