feat: add /jobs API

This API will be later tied to jobs as defined for specific flows
(post-training, eval, etc.) through the common scheduler mechanism.

Note: At the moment, API does nothing useful. (Except returning Not
Implemented errors when called.)

This is an alternative to developing per-flow jobs APIs. Eventually,
once /jobs API is implemented, we should be able to deprecate existing
APIs under /v1/post-training/, /v1/eval/ etc.

See #1587 (tracker)
See #1238 (design details)

Note: This is an alternative path to #1582 and #1583.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
Ihar Hrachyshka 2025-03-12 16:15:30 -04:00
parent 0fdb15bcc7
commit 90799cdcee
12 changed files with 557 additions and 11 deletions

View file

@ -230,6 +230,41 @@
}
}
},
"/v1/jobs/{job_id}/cancel": {
"post": {
"responses": {
"200": {
"description": "OK"
},
"400": {
"$ref": "#/components/responses/BadRequest400"
},
"429": {
"$ref": "#/components/responses/TooManyRequests429"
},
"500": {
"$ref": "#/components/responses/InternalServerError500"
},
"default": {
"$ref": "#/components/responses/DefaultError"
}
},
"tags": [
"Jobs"
],
"description": "",
"parameters": [
{
"name": "job_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
]
}
},
"/v1/post-training/job/cancel": {
"post": {
"responses": {
@ -925,6 +960,81 @@
]
}
},
"/v1/jobs/{job_id}": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/JobInfo"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest400"
},
"429": {
"$ref": "#/components/responses/TooManyRequests429"
},
"500": {
"$ref": "#/components/responses/InternalServerError500"
},
"default": {
"$ref": "#/components/responses/DefaultError"
}
},
"tags": [
"Jobs"
],
"description": "",
"parameters": [
{
"name": "job_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
]
},
"delete": {
"responses": {
"200": {
"description": "OK"
},
"400": {
"$ref": "#/components/responses/BadRequest400"
},
"429": {
"$ref": "#/components/responses/TooManyRequests429"
},
"500": {
"$ref": "#/components/responses/InternalServerError500"
},
"default": {
"$ref": "#/components/responses/DefaultError"
}
},
"tags": [
"Jobs"
],
"description": "",
"parameters": [
{
"name": "job_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
]
}
},
"/v1/inference/embeddings": {
"post": {
"responses": {
@ -2568,6 +2678,39 @@
]
}
},
"/v1/jobs": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListJobsResponse"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest400"
},
"429": {
"$ref": "#/components/responses/TooManyRequests429"
},
"500": {
"$ref": "#/components/responses/InternalServerError500"
},
"default": {
"$ref": "#/components/responses/DefaultError"
}
},
"tags": [
"Jobs"
],
"description": "",
"parameters": []
}
},
"/v1/models": {
"get": {
"responses": {
@ -4715,6 +4858,12 @@
"CompletionResponse": {
"type": "object",
"properties": {
"metrics": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MetricEvent"
}
},
"content": {
"type": "string",
"description": "The generated completion text"
@ -5082,6 +5231,12 @@
"CompletionResponseStreamChunk": {
"type": "object",
"properties": {
"metrics": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MetricEvent"
}
},
"delta": {
"type": "string",
"description": "New content generated since last chunk. This can be one or more tokens."
@ -7094,6 +7249,73 @@
],
"title": "UnionType"
},
"JobArtifact": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
},
"uri": {
"type": "string"
},
"metadata": {
"type": "object",
"title": "dict",
"description": "dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)"
}
},
"additionalProperties": false,
"required": [
"name",
"type",
"uri",
"metadata"
],
"title": "JobArtifact"
},
"JobInfo": {
"type": "object",
"properties": {
"uuid": {
"type": "string"
},
"type": {
"type": "string"
},
"status": {
"type": "string"
},
"scheduled_at": {
"type": "string",
"format": "date-time"
},
"started_at": {
"type": "string",
"format": "date-time"
},
"completed_at": {
"type": "string",
"format": "date-time"
},
"artifacts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/JobArtifact"
}
}
},
"additionalProperties": false,
"required": [
"uuid",
"type",
"status",
"artifacts"
],
"title": "JobInfo"
},
"Model": {
"type": "object",
"properties": {
@ -8157,6 +8379,22 @@
"title": "ListFileResponse",
"description": "Response representing a list of file entries."
},
"ListJobsResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/JobInfo"
}
}
},
"additionalProperties": false,
"required": [
"data"
],
"title": "ListJobsResponse"
},
"ListModelsResponse": {
"type": "object",
"properties": {
@ -10119,6 +10357,9 @@
{
"name": "Inspect"
},
{
"name": "Jobs"
},
{
"name": "Models"
},
@ -10169,6 +10410,7 @@
"Files (Coming Soon)",
"Inference",
"Inspect",
"Jobs",
"Models",
"PostTraining (Coming Soon)",
"Safety",