-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rearrange ray initialization to avoid os.fork() RuntimeWarning * Locate ray initialization to avoid os.fork() RuntimeWarning * Remove module-level ray.init call * Attempt to clarify comment * Bug fix
- Loading branch information
Showing
7 changed files
with
59 additions
and
46 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 |
---|---|---|
@@ -1,21 +1,39 @@ | ||
""" | ||
Configure the environment in which doctests run. This is necessary | ||
because `np` is used in doc strings for jax functions | ||
(e.g. `linear_transpose`) that get pulled into `scico/__init__.py`. | ||
Also allow `snp` to be used without explicitly importing, and add | ||
`level` parameter. | ||
Configure pytest. | ||
""" | ||
|
||
import numpy as np | ||
|
||
import pytest | ||
|
||
try: | ||
import ray # noqa: F401 | ||
except ImportError: | ||
have_ray = False | ||
else: | ||
have_ray = True | ||
ray.init(num_cpus=1) # call required to be here: see ray-project/ray#44087 | ||
|
||
import scico.numpy as snp | ||
|
||
|
||
def pytest_sessionstart(session): | ||
"""Initialize before start of test session.""" | ||
# placeholder: currently unused | ||
|
||
|
||
def pytest_sessionfinish(session, exitstatus): | ||
"""Clean up after end of test session.""" | ||
ray.shutdown() | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def add_modules(doctest_namespace): | ||
"""Add common modules for use in docstring examples.""" | ||
"""Add common modules for use in docstring examples. | ||
Necessary because `np` is used in doc strings for jax functions | ||
(e.g. `linear_transpose`) that get pulled into `scico/__init__.py`. | ||
Also allow `snp` to be used without explicitly importing. | ||
""" | ||
doctest_namespace["np"] = np | ||
doctest_namespace["snp"] = snp |
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
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