From 3a757999009c8c201a8a39b7963024331636450e Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 13 Mar 2025 11:09:37 -0700 Subject: [PATCH] jobs common --- llama_stack/apis/common/job_types.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/llama_stack/apis/common/job_types.py b/llama_stack/apis/common/job_types.py index bc070017b..cad2bcec8 100644 --- a/llama_stack/apis/common/job_types.py +++ b/llama_stack/apis/common/job_types.py @@ -3,21 +3,35 @@ # # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +from datetime import datetime from enum import Enum +from typing import Optional from pydantic import BaseModel from llama_stack.schema_utils import json_schema_type -@json_schema_type -class Job(BaseModel): - job_id: str - - -@json_schema_type class JobStatus(Enum): completed = "completed" in_progress = "in_progress" failed = "failed" scheduled = "scheduled" + cancelled = "cancelled" + + +@json_schema_type +class CommonJobFields(BaseModel): + """Common fields for all jobs. + :param id: The ID of the job. + :param status: The status of the job. + :param created_at: The time the job was created. + :param finished_at: The time the job finished. + :param error: If status of the job is failed, this will contain the error message. + """ + + id: str + status: JobStatus + created_at: datetime + finished_at: Optional[datetime] = None + error: Optional[str] = None