-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on "Model is not Available" errors in tests (#1659)
* Check disk/memory usage if we get unsat results * Expand "Model unavailable" message * Ignore missing psutil imports * Add resource checks to CLI application
- Loading branch information
Eric Hennenfent
committed
Apr 10, 2020
1 parent
d082284
commit 1e23f7a
Showing
5 changed files
with
53 additions
and
4 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,33 @@ | ||
import logging | ||
from psutil import disk_usage, virtual_memory | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
|
||
#: Percentage of _used_ memory to warn above | ||
memory_warn_percent = 95.0 | ||
#: Number of free bytes to warn below | ||
memory_warn_absolute = (1024 ** 3) // 2 | ||
#: Number of free bytes to warn below | ||
disk_warn = 1024 ** 3 | ||
|
||
|
||
def check_memory_usage(): | ||
""" | ||
Print a warning message if the available memory space is below memory_warn | ||
""" | ||
usage = virtual_memory() | ||
if usage.percent >= 95.0 or usage.available < memory_warn_absolute: | ||
logger.warning( | ||
"System only has %d kib of virtual memory available", usage.available // 1024 | ||
) | ||
|
||
|
||
def check_disk_usage(path="."): | ||
""" | ||
Print a warning message if the available disk space is below disk_warn | ||
:param path: System path to check. Defaults to the current directory. | ||
""" | ||
usage = disk_usage(path) | ||
if usage.free < (disk_warn): | ||
logger.warning("Only %d kib of disk space remaining", usage.free // 1024) |
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