Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

logger = logging.getLogger(__name__)

# HTTP statuses under which a polled vLLM video job may still carry its own failed status.
_VIDEO_FAILURE_STATUSES = {400, 500}

_REASONS = {
'input': ('生成服务拒绝了输入内容或参数。', '请检查生成要求、参数和模型支持范围。'),
'reference': ('生成服务拒绝了参考素材。', '请更换符合服务要求的参考素材,再决定是否重新生成。'),
Expand Down Expand Up @@ -132,9 +135,9 @@ def provider_failure(value, *, stage, headers=None, http_status=None, secrets=()
suggestion = '请核对原任务和结果链接,恢复下载前不要直接重新生成。'
terminal_status = None
if stage == 'poll' and value.get('status') in {'failed', 'cancelled', 'expired'}:
# vLLM can return a failed Video object with HTTP 500. A gateway error
# vLLM can return a failed Video object with HTTP 400 or 500. A gateway error
# is not terminal evidence: require the queried job's exact identity.
if http_status == 200 or (http_status == 500 and expected_task_id
if http_status == 200 or (http_status in _VIDEO_FAILURE_STATUSES and expected_task_id
and value.get('object') == 'video' and value.get('id') == expected_task_id):
terminal_status = value['status']
if terminal_status == 'failed' and (category == 'temporary' or provider == 'kling' and category == 'provider'):
Expand Down Expand Up @@ -162,7 +165,7 @@ async def checked(response, *, stage, secrets=()):
except (ValueError, UnicodeError):
value = None
expected_task_id = None
if stage == 'poll' and response.status_code == 500:
if stage == 'poll' and response.status_code in _VIDEO_FAILURE_STATUSES:
try:
match = re.search(r'/videos/([^/]+)$', response.request.url.path)
except RuntimeError: # Detached responses cannot prove task identity.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_self_hosted_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ async def run():

@pytest.mark.parametrize('status, object_type, returned_id, terminal', [
(200, 'video', 'original-remote', True),
(400, 'video', 'original-remote', True),
(400, 'video', 'another-job', False),
(500, 'video', 'original-remote', True),
(500, 'video', 'another-job', False),
(500, 'error', 'original-remote', False),
Expand Down
Loading