forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
67 lines (53 loc) · 1.82 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from .interface import ToolStdioExitCode
from .interface import ToolStdioRegex
def error_on_exit_code(out_of_memory_exit_code=None):
exit_codes = []
if out_of_memory_exit_code:
exit_code_oom = ToolStdioExitCode()
exit_code_oom.range_start = int(out_of_memory_exit_code)
exit_code_oom.range_end = int(out_of_memory_exit_code)
_set_oom(exit_code_oom)
exit_codes.append(exit_code_oom)
exit_code_lower = ToolStdioExitCode()
exit_code_lower.range_start = float("-inf")
exit_code_lower.range_end = -1
_set_fatal(exit_code_lower)
exit_codes.append(exit_code_lower)
exit_code_high = ToolStdioExitCode()
exit_code_high.range_start = 1
exit_code_high.range_end = float("inf")
_set_fatal(exit_code_high)
exit_codes.append(exit_code_high)
return exit_codes, []
def aggressive_error_checks():
exit_codes, _ = error_on_exit_code()
# these regexes are processed as case insensitive by default
regexes = [
_oom_regex("MemoryError"),
_oom_regex("std::bad_alloc"),
_oom_regex("java.lang.OutOfMemoryError"),
_oom_regex("Out of memory"),
_error_regex("exception:"),
_error_regex("error:")
]
return exit_codes, regexes
def _oom_regex(match):
regex = ToolStdioRegex()
_set_oom(regex)
regex.match = match
regex.stdout_match = True
regex.stderr_match = True
return regex
def _error_regex(match):
regex = ToolStdioRegex()
_set_fatal(regex)
regex.match = match
regex.stdout_match = True
regex.stderr_match = True
return regex
def _set_oom(obj):
from galaxy.jobs.error_level import StdioErrorLevel
obj.error_level = StdioErrorLevel.FATAL_OOM
def _set_fatal(obj):
from galaxy.jobs.error_level import StdioErrorLevel
obj.error_level = StdioErrorLevel.FATAL