-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6029 from niboshi/doctest-single-gpu-environment
Allow doctest to run in single-GPU environment
- Loading branch information
Showing
6 changed files
with
38 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import pkg_resources | ||
|
||
|
||
_gpu_limit = int(os.getenv('CHAINER_TEST_GPU_LIMIT', '-1')) | ||
|
||
|
||
def skipif(condition): | ||
# In the readthedocs build, doctest should never be skipped, because | ||
# otherwise the code would disappear from the documentation. | ||
if os.environ.get('READTHEDOCS') == 'True': | ||
return False | ||
return condition | ||
|
||
|
||
def skipif_requires_satisfied(*requirements): | ||
ws = pkg_resources.WorkingSet() | ||
try: | ||
ws.require(*requirements) | ||
except pkg_resources.ResolutionError: | ||
return False | ||
return skipif(True) | ||
|
||
|
||
def skipif_not_enough_cuda_devices(device_count): | ||
return skipif(0 <= _gpu_limit < device_count) |
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