-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test that lazily loaded modules are not imported by default * pandas compability * lazy load figure factory
- Loading branch information
Showing
4 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import multiprocessing | ||
import sys | ||
|
||
|
||
def check_loaded(queue, modules): | ||
import xiplot # noqa: F401 | ||
import xiplot.setup # noqa: F401 | ||
|
||
queue.put([mod in sys.modules for mod in modules]) | ||
|
||
|
||
def test_ensure_lazyload(): | ||
# This tests that the following packages are not imported when xiplot is | ||
# imported, so that they can be lazily loaded in the WASM version. | ||
# This test starts a new Python (multi-)process using "spawn" to check the | ||
# imports in a clean environment. | ||
modules = ["sklearn", "jsonschema", "plotly.figure_factory"] | ||
ctx = multiprocessing.get_context("spawn") | ||
q = ctx.Queue() | ||
p = ctx.Process(target=check_loaded, args=(q, modules)) | ||
p.start() | ||
for mod, loaded in zip(modules, q.get()): | ||
assert not loaded, f"{mod} should be lazily loaded" | ||
p.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters