Skip to content

Commit

Permalink
handle more codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Kuo (Danswer) committed Feb 14, 2025
1 parent b257d85 commit e40a844
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions backend/onyx/background/celery/tasks/indexing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,33 +107,42 @@ class IndexingWatchdogTerminalStatus(str, Enum):
# the watchdog terminated the task due to no activity
TERMINATED_BY_ACTIVITY_TIMEOUT = "terminated_by_activity_timeout"

OUT_OF_MEMORY = "out_of_memory"

@property
def code(self) -> int:
_ENUM_TO_CODE: dict[IndexingWatchdogTerminalStatus, int] = {
IndexingWatchdogTerminalStatus.OUT_OF_MEMORY: 137,
IndexingWatchdogTerminalStatus.BLOCKED_BY_DELETION: 248,
IndexingWatchdogTerminalStatus.BLOCKED_BY_STOP_SIGNAL: 249,
IndexingWatchdogTerminalStatus.FENCE_NOT_FOUND: 250,
IndexingWatchdogTerminalStatus.FENCE_READINESS_TIMEOUT: 251,
IndexingWatchdogTerminalStatus.FENCE_MISMATCH: 252,
IndexingWatchdogTerminalStatus.TASK_ALREADY_RUNNING: 253,
IndexingWatchdogTerminalStatus.INDEX_ATTEMPT_MISMATCH: 254,
IndexingWatchdogTerminalStatus.CONNECTOR_EXCEPTIONED: 255,
}

return _ENUM_TO_CODE[self]

@classmethod
def from_code(cls, code: int) -> "IndexingWatchdogTerminalStatus":
_CODE_TO_ENUM: dict[int, IndexingWatchdogTerminalStatus] = {
137: IndexingWatchdogTerminalStatus.OUT_OF_MEMORY,
248: IndexingWatchdogTerminalStatus.BLOCKED_BY_DELETION,
249: IndexingWatchdogTerminalStatus.BLOCKED_BY_STOP_SIGNAL,
250: IndexingWatchdogTerminalStatus.FENCE_NOT_FOUND,
251: IndexingWatchdogTerminalStatus.FENCE_READINESS_TIMEOUT,
252: IndexingWatchdogTerminalStatus.FENCE_MISMATCH,
253: IndexingWatchdogTerminalStatus.TASK_ALREADY_RUNNING,
254: IndexingWatchdogTerminalStatus.INDEX_ATTEMPT_MISMATCH,
255: IndexingWatchdogTerminalStatus.CONNECTOR_EXCEPTIONED,
}

return _CODE_TO_ENUM[code]
if code in _CODE_TO_ENUM:
return _CODE_TO_ENUM[code]

return IndexingWatchdogTerminalStatus.UNDEFINED


class SimpleJobResult:
Expand Down Expand Up @@ -832,7 +841,9 @@ def process_job_result(
)
)
else:
result.status = IndexingWatchdogTerminalStatus.CONNECTOR_EXCEPTIONED
if result.exit_code is not None:
result.status = IndexingWatchdogTerminalStatus.from_code(result.exit_code)

result.exception_str = job.exception()

return result
Expand Down

0 comments on commit e40a844

Please sign in to comment.