Skip to content

Commit 021d0a0

Browse files
committed
added an enum for exit codes
1 parent 6d030d0 commit 021d0a0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/discord-cluster-manager/consts.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import Enum, IntEnum
22
from typing import Type
33

44

@@ -25,6 +25,22 @@ class ModalGPU(Enum):
2525
H100 = "H100"
2626

2727

28+
class ExitCode(IntEnum):
29+
"""
30+
Exit codes for our runners. These are just the codes actively return,
31+
others are possible (e.g., exiting due to segfault, permissions, signal, ...)
32+
"""
33+
34+
# program ran successfully
35+
SUCCESS = 0
36+
# a cuda API call failed
37+
CUDA_FAIL = 110
38+
# could not setup file descriptor for custom pipe
39+
PIPE_FAILED = 111
40+
# didn't crash, but tests failed
41+
VALIDATE_FAIL = 112
42+
43+
2844
def combine_enums(enums: list[Type[Enum]], combined_name: str) -> Enum:
2945
combined_members = {}
3046
for enum in enums:

src/discord-cluster-manager/run_eval.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66
from typing import Optional
77

8-
from consts import CUDA_FLAGS
8+
from consts import CUDA_FLAGS, ExitCode
99

1010

1111
@dataclasses.dataclass
@@ -141,10 +141,8 @@ def run_program(args: list[str]) -> RunResult:
141141
key, _, value = line.partition(":")
142142
result_dict[key.strip()] = value.strip()
143143

144-
# 0 everything was fine
145-
# 112 program ran fine, but we detected a test failure
146144
return RunResult(
147-
success=run_process.returncode == 0,
145+
success=run_process.returncode == ExitCode.SUCCESS,
148146
command=_make_cmd(run_process.args),
149147
stdout=run_process.stdout,
150148
stderr=run_process.stderr,

0 commit comments

Comments
 (0)