Skip to content

Optional cached imports - #72

Open
kristoffer-gustafsson wants to merge 5 commits into
multiscale:developfrom
kristoffer-gustafsson:optional-cached-imports
Open

kristoffer-gustafsson wants to merge 5 commits into
multiscale:developfrom
kristoffer-gustafsson:optional-cached-imports

Conversation

@kristoffer-gustafsson

Copy link
Copy Markdown

The ymmsl_cache assumes that the YMMSL_PATH and sys.path does not change between resolve calls, but in fact it can.
If it does, the cached module imports can become stale.

Therefore I have added this contract explicitly in the doc-string of the resolve method, along with an option to clear the cache before resolving.

This test checks that some warning is logged when multiple entry points are found for one module. However, this part of the code is never reached if on the second call with reuse_cached_imports = True instead of False. That is because the entrypoints are cached in the previous call, which skips  _load_from_entrypoints where the warning is raised.

Therefore ymmsl_cache is cleared before and after each test to ensure a clean slate.

The failed test::
FAILED ymmsl/v0_2/tests/test_resolver.py::test_resolve_entrypoints_duplicate_name[True] - assert 0 == 1
 +  where 0 = len([])
@LourensVeen LourensVeen self-assigned this Sep 25, 2026
@LourensVeen
LourensVeen self-requested a review September 25, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants