Backend REST API#
- POST /auth/#
Auth User
Authenticate user and return access and refresh tokens
- Args:
response (Response): Response that will be returned to the client form_data (OAuth2PasswordRequestForm, optional): Username and Password.
Defaults to Depends().
- db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB Connection.
Defaults to Depends(get_db).
- Raises:
HTTPException: 401 Unauthorized if credentials are invalid HTTPException: 404 Not Found if user does not exist
- Returns:
Dict[str, str]: Response containing access and refresh tokens. Credentials are saved as cookies.
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "access_token": "string", "refresh_token": "string", "token_type": "bearer" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /auth/refresh#
Get Refresh Token
Use refresh token to get new access token when access token expires.
- Args:
request (Request): Incoming request response (Response): Response that will be returned to the client db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB Connection.
Defaults to Depends(get_db).
csrf (CsrfProtect, optional): Perform CSRF protection. Defaults to Depends().
- Raises:
HTTPException: 404 if user does not exist HTTPException: 403 if refresh token expired CREDENTIALS_EXCEPTION: 401 if credentials are invalid HTTPException: 409 if CSRF token is invalid HTTPException: 400 otherwise
- Returns:
Optional[Dict[str, str]]: Access token if refresh token is valid
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "access_token": "string", "refresh_token": "string", "token_type": "bearer" }
- DELETE /auth/logout#
Logout User
Logout user by deleting cookies
- Args:
response (Response): Response that will be returned to the client
- Raises:
HTTPException: 500 if an error occurs
- Status Codes:
204 No Content – Successful Response
- GET /auth/is_admin#
Verify Admin
This endpoint mostly exists just to test that auth code is working
Example request:
GET /auth/is_admin HTTP/1.1 Host: example.com
- Status Codes:
204 No Content – Successful Response
- PUT /buckets/video#
Replace Video
Replaces a video in the MinIO bucket
- Args:
new_video (UploadFile, optional): New video. Defaults to Form(). old_video_location (Optional[str], optional): Location of video to replace.
Defaults to Form(None).
s3_client (Minio, optional): Minio client. Defaults to Depends(minio_api_client).
- Raises:
HTTPException: 500 if something went wrong
- Returns:
Dict[str, str]: Location of the new video in the bucket
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "video_location": "string" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /buckets/video#
Upload Video
Uploads a video to the MinIO bucket
- Args:
video (UploadFile): Video file to upload s3_client (Minio, optional): Minio client. Defaults to Depends(minio_api_client).
- Raises:
HTTPException: 500 if something went wrong
- Returns:
Dict[str, str]: Location of the video in the bucket
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "video_location": "string" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /models/_db/options/filters/#
Get Available Filters
Get available filters for model zoo search page
- Args:
- db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
- Returns:
Dict[str, List[str]]: All available tags, frameworks, and tasks
Example request:
GET /models/_db/options/filters/ HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "tags": [ "string" ], "frameworks": [ "string" ], "tasks": [ "string" ] }
- GET /models/{creator_user_id}/{model_id}#
Get Model Card By Id
Get model card by composite ID: creator_user_id/model_id
- Args:
model_id (str): Model ID to search for creator_user_id (str): Creator user ID to search for db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
- Raises:
HTTPException: 404 if model card not found
- Returns:
Dict: Model card
- Parameters:
model_id (string) –
creator_user_id (string) –
- Query Parameters:
convert_s3 (boolean) –
Example request:
GET /models/{creator_user_id}/{model_id} HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- PUT /models/{creator_user_id}/{model_id}#
Update Model Card Metadata By Id
Update model card metadata by ID
- Args:
model_id (str): Model Id creator_user_id (str): Creator user id card (UpdateModelCardModel): Updated model card tasks (BackgroundTasks): Background tasks to run db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
user (TokenData, optional): User data. Defaults to Depends(get_current_user).
- Raises:
HTTPException: 404 if model card does not exist HTTPException: 403 if user does not have permission to update model card
- Returns:
Optional[Dict]: Updated model card metadata
- Parameters:
model_id (string) –
creator_user_id (string) –
Example request:
PUT /models/{creator_user_id}/{model_id} HTTP/1.1 Host: example.com Content-Type: application/json { "title": "string", "description": "string", "explanation": "string", "usage": "string", "limitations": "string", "markdown": "string", "performance": "string", "tags": [ "string" ], "task": "string", "frameworks": [ "string" ], "pointOfContact": "string", "owner": "string", "videoLocation": "string", "inferenceServiceName": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ], "experiment": { "connector": "", "experimentId": "string" }, "dataset": { "connector": "", "datasetId": "string" } }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "title": "string", "markdown": "string", "performance": "string", "task": "string", "inferenceServiceName": "string", "videoLocation": "string", "tags": [ "string" ], "frameworks": [ "string" ], "description": "string", "explanation": "string", "usage": "string", "limitations": "string", "owner": "string", "pointOfContact": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ], "experiment": { "connector": "", "experimentId": "string" }, "dataset": { "connector": "", "datasetId": "string" }, "_id": "string", "creatorUserId": "string", "modelId": "string", "created": "string", "lastModified": "string" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- DELETE /models/{creator_user_id}/{model_id}#
Delete Model Card By Id
Delete model card by composite key of Creator User ID and Model ID
- Args:
model_id (str): Model Id creator_user_id (str): Creator user id card (UpdateModelCardModel): Updated model card tasks (BackgroundTasks): Background tasks to run db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
user (TokenData, optional): User data. Defaults to Depends(get_current_user).
- Raises:
HTTPException: 500 if arbitrary error occurs
- Parameters:
model_id (string) –
creator_user_id (string) –
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /models/#
Search Cards
Search model cards
- Args:
db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection. Defaults to Depends(get_db). page (int, optional): Page number. Defaults to Query(default=1, alias=”p”, gt=0). rows_per_page (int, optional): Rows per page. Defaults to Query(default=10, alias=”n”, ge=0). descending (bool, optional): Order to return results in. Defaults to Query(default=False, alias=”desc”). sort_by (str, optional): Sort by field. Defaults to Query(default=”_id”, alias=”sort”). generic_search_text (Optional[str], optional): Search through any relevant text fields. Defaults to Query(default=None, alias=”genericSearchText”). tasks (Optional[List[str]], optional): Search by task. Defaults to Query(default=None, alias=”tasks[]”). tags (Optional[List[str]], optional): Search by task. Defaults to Query(default=None, alias=”tags[]”). frameworks (Optional[List[str]], optional): Search by framework. Defaults to Query( default=None, alias=”frameworks[]” ). creator_user_id (Optional[str], optional): Search by creator. Defaults to Query(default=None, alias=”creator”). return_attr (Optional[List[str]], optional): Which fields to return. Defaults to Query(default=None, alias=”return[]”). all (Optional[bool], optional): Whether to return all results. Defaults to Query(default=None).
- Returns:
Dict: A dictionary containing the results and pagination information
- Query Parameters:
p (integer) –
n (integer) –
desc (boolean) –
sort (string) –
genericSearchText (string) –
title (string) –
tasks[] (array) –
tags[] (array) –
frameworks[] (array) –
creator (string) –
creatorUserIdPartial (string) –
return[] (array) –
all (boolean) –
Example request:
GET /models/ HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "results": [ {} ], "total": 1 }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /models/#
Create Model Card Metadata
Create model card metadata
- Args:
card (ModelCardModelIn): Model card tasks (BackgroundTasks): Background tasks to run db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
user (TokenData, optional): User data. Defaults to Depends(get_current_user).
- Raises:
HTTPException: 409 if model card already exists
- Returns:
Dict: Model card metadata
Example request:
POST /models/ HTTP/1.1 Host: example.com Content-Type: application/json { "title": "string", "markdown": "string", "performance": "string", "task": "string", "inferenceServiceName": "string", "videoLocation": "string", "tags": [ "string" ], "frameworks": [ "string" ], "description": "string", "explanation": "string", "usage": "string", "limitations": "string", "owner": "string", "pointOfContact": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ], "experiment": { "connector": "", "experimentId": "string" }, "dataset": { "connector": "", "datasetId": "string" } }
- Status Codes:
Successful Response
Example response:
HTTP/1.1 201 Created Content-Type: application/json { "title": "string", "markdown": "string", "performance": "string", "task": "string", "inferenceServiceName": "string", "videoLocation": "string", "tags": [ "string" ], "frameworks": [ "string" ], "description": "string", "explanation": "string", "usage": "string", "limitations": "string", "owner": "string", "pointOfContact": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ], "experiment": { "connector": "", "experimentId": "string" }, "dataset": { "connector": "", "datasetId": "string" }, "_id": "string", "creatorUserId": "string", "modelId": "string", "created": "string", "lastModified": "string" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /models/{creator_user_id}#
Get Model Cards By User
Get all model cards by a user
- Args:
creator_user_id (str): Creator user id db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
- return_attr (Optional[List[str]], optional): Fields to return.
Defaults to Query(None, alias=”return”).
- Returns:
Dict: Results and pagination information
- Parameters:
creator_user_id (string) –
- Query Parameters:
return (array) –
Example request:
GET /models/{creator_user_id} HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "results": [ {} ], "total": 1 }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- DELETE /models/multi#
Delete Multiple Model Cards
Delete multiple model cards by List of composite keys of Creator User ID and Model ID
- Args:
card_package (modelCardPackage): List of Dictionaries containing models with composite ID identifiers to be removed card (UpdateModelCardModel): Updated model card tasks (BackgroundTasks): Background tasks to run db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
user (TokenData, optional): User data. Defaults to Depends(get_current_user).
- Raises:
HTTPException: 500 if arbitrary error occurs
Example request:
DELETE /models/multi HTTP/1.1 Host: example.com Content-Type: application/json { "card_package": [ { "model_id": "string", "creator_user_id": "string" } ] }
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /models/export#
Export Models
Example request:
POST /models/export HTTP/1.1 Host: example.com Content-Type: application/json { "card_package": [ { "model_id": "string", "creator_user_id": "string" } ] }
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /experiments/{exp_id}#
Get Experiment
Get experiment by ID.
- Args:
exp_id (str): Experiment ID connector (Connector): Connector to use return_plots (bool, optional): If plots should be returned. Defaults to True. return_artifacts (bool, optional): If artifacts should be returned. Defaults to True.
- Raises:
HTTPException: 404 Not Found if experiment does not exist HTTPException: 500 Internal Server Error if error occurs
- Returns:
Dict: Experiment details
- Parameters:
exp_id (string) –
- Query Parameters:
connector (string) – (Required)
return_plots (boolean) –
return_artifacts (boolean) –
Example request:
GET /experiments/{exp_id}?connector= HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": "string", "owner": "string", "name": "string", "project_name": "string", "tags": [ "string" ], "frameworks": [ "string" ], "config": {}, "scalars": [ {} ], "plots": [ {} ], "artifacts": {} }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /experiments/clone#
Clone Experiment
Clone experiment. (Not implemented yet.)
- Args:
item (ClonePackageModel): Item to clone connector (Connector): Experiment connector
- Returns:
Dict: Details of cloned experiment
- Query Parameters:
connector (string) – (Required)
Example request:
POST /experiments/clone?connector= HTTP/1.1 Host: example.com Content-Type: application/json { "id": "string", "clone_name": "string" }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /datasets/search#
Search Datasets
Search endpoint for any datasets stored in the current data connector
- Args:
query (FindDatasetModel): Search query connectors (Optional[List[Connector]]): Data connector.
If not specified
- Returns:
List[Dict]: List of dataset metadata
- Query Parameters:
connectors[] (array) –
Example request:
POST /datasets/search HTTP/1.1 Host: example.com Content-Type: application/json { "id": {}, "name": "string", "tags": [ "string" ], "project": "string" }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": "string", "name": "string", "created": "string", "tags": [ "string" ], "project": "string", "files": {}, "default_remote": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ] } ]
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /datasets/{dataset_id}#
Get Dataset By Id
Get a dataset from it’s ID
- Args:
dataset_id (str): ID of dataset (e.g ClearML Dataset ID) connector (Connector): Data connector type
- Raises:
HTTPException: 404 Not Found if dataset not found
- Returns:
DatasetModel: Dataset with that ID
- Parameters:
dataset_id (string) –
- Query Parameters:
connector (string) – (Required)
Example request:
GET /datasets/{dataset_id}?connector= HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": "string", "name": "string", "created": "string", "tags": [ "string" ], "project": "string", "files": {}, "default_remote": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ] }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /datasets/#
Create Dataset
Create a new dataset, based on a dataset file uploaded to it
- Args:
file (UploadFile, optional): Archived dataset (e.g zip). Defaults to File(…). dataset_name (str, optional): Name of dataset. Defaults to Form(…). project_name (str, optional): Name of project to uplaod to. Defaults to Form(…). connector(Connector): Data connector to use. output_url (Optional[str], optional): Remote URL to upload file to. Defaults to Form(default=None).
- Raises:
HTTPException: 413 Request Entity Too Large if dataset size is too large HTTPException: 415 Unsupported Media Type if wrong file type HTTPException: 500 Internal Server Error if any IOErrors
- Returns:
DatasetModel : Created dataset
- Status Codes:
Successful Response
Example response:
HTTP/1.1 201 Created Content-Type: application/json { "id": "string", "name": "string", "created": "string", "tags": [ "string" ], "project": "string", "files": {}, "default_remote": "string", "artifacts": [ { "artifactType": "string", "name": "string", "url": "string", "timestamp": "string", "framework": "string" } ] }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /iam/add#
Add User
Function to add a user to the MongoDB after reciveing a POST call to the endpoint
- Args:
item (UserInsert): The item that contains the user information to be sent to the database for storage db (Any = Depends(get_db)): This retieves the client that is connected to the database.
- Returns:
JSONResponse: A Response object with a corresponding code depending on the success of the call or a failure for whatever reason.
Example request:
POST /iam/add HTTP/1.1 Host: example.com Content-Type: application/json { "name": "string", "user_id": "string", "password": "string", "password_confirm": "string", "admin_priv": true }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- DELETE /iam/delete#
Delete User
Delete a user from the database
- Args:
userid (UserRemoval): User ID to delete db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
- Raises:
HTTPException: 404 if user not found
Example request:
DELETE /iam/delete HTTP/1.1 Host: example.com Content-Type: application/json { "users": [ "string" ] }
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- PUT /iam/edit#
Update User
Example request:
PUT /iam/edit HTTP/1.1 Host: example.com Content-Type: application/json { "name": "string", "user_id": "string", "password": "string", "password_confirm": "string", "admin_priv": true }
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- PUT /iam/edit/multi#
Update Many User
Example request:
PUT /iam/edit/multi HTTP/1.1 Host: example.com Content-Type: application/json { "users": [ "string" ], "priv": true }
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /iam/#
Get Users
Get a list of users from the database
- Args:
pages_user (UserPage): Pagination input descending (bool, optional): Order of results. Defaults to Query(default=True, alias=”desc”). sort_by (str, optional): Sort field. Defaults to Query(default=”lastModified”, alias=”sort”). db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
- Raises:
HTTPException: 422 if unable to get users HTTPException: 404 if user not found
- Returns:
Dict: _description_
- Query Parameters:
desc (boolean) –
sort (string) –
Example request:
POST /iam/ HTTP/1.1 Host: example.com Content-Type: application/json { "page_num": 1, "user_num": 1, "name": "string", "userId": "string", "admin_priv": 1, "last_modified_range": {}, "date_created_range": {} }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /engines/{service_name}/logs#
Get Inference Engine Service Logs
Get logs for an inference service
- Args:
service_name (str): Name of the service request (Request): FastAPI Request object k8s_client (ApiClient, optional): K8S Client. Defaults to Depends(get_k8s_client).
- Raises:
HTTPException: 404 Not Found if service does not exist HTTPException: 500 Internal Server Error if there is an error getting the service logs
- Returns:
EventSourceResponse: SSE response with logs
- Parameters:
service_name (string) –
Example request:
GET /engines/{service_name}/logs HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- PATCH /engines/{service_name}/scale/{replicas}#
Scale Inference Engine Deployments
Scale the number of replicas of the deployment
- Args:
service_name (str): Name of the service replicas (int, optional): Number of replicas. Defaults to Path(ge=0, le=3). k8s_client (ApiClient, optional): K8S Client. Defaults to Depends(get_k8s_client).
- Raises:
HTTPException: 404 Not Found if service does not exist HTTPException: 500 Internal Server Error if there is an error scaling the service
- Parameters:
service_name (string) –
replicas (integer) –
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /engines/{service_name}#
Get Inference Engine Service
Get Inference Engine Service
- Args:
service_name (str): Name of the service db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
- Raises:
HTTPException: 404 Not Found if service does not exist
- Returns:
Dict: Service details
- Parameters:
service_name (string) –
Example request:
GET /engines/{service_name} HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "modelId": "string", "imageUri": "string", "containerPort": 1, "env": {}, "numGpus": 1.0, "_id": "string", "inferenceUrl": "string", "ownerId": "string", "serviceName": "string", "created": "2024-03-05T02:54:36.571224", "lastModified": "2024-03-05T02:54:36.571224", "host": "string", "path": "string", "protocol": "string", "backend": "knative" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- DELETE /engines/{service_name}#
Delete Inference Engine Service
Delete a deployed inference engine from the K8S cluster.
- Parameters:
service_name (string) – Name of KNative service, defaults to Path(description=”Name of KService to Delete”)
k8s_client (ApiClient, optional) – Python K8S Client, defaults to Depends(get_k8s_client)
service_name – Name of KService to Delete
- Raises HTTPException:
500 Internal Server Error if deletion fails
- Status Codes:
204 No Content – Successful Response
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- PATCH /engines/{service_name}#
Update Inference Engine Service
Update an existing inference engine inside the K8S cluster
- Parameters:
service (InferenceEngineService) – Configuration (service name and Image URI) of updated Inference Engine
k8s_client (ApiClient, optional) – Python K8S client, defaults to Depends(get_k8s_client)
service_name (string) –
- Raises HTTPException:
500 Internal Server Error if failed to update
Example request:
PATCH /engines/{service_name} HTTP/1.1 Host: example.com Content-Type: application/json { "imageUri": "string", "containerPort": 1, "env": {}, "numGpus": 1.0 }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /engines/{service_name}/status#
Get Inference Engine Service Status
Get status of an inference service. This is typically used to give liveness/readiness probes for the service.
- Args:
service_name (str): Name of the service k8s_client (ApiClient, optional): K8S Client. Defaults to Depends(get_k8s_client).
- Raises:
HTTPException: 404 Not Found if service does not exist HTTPException: 500 Internal Server Error if there is an error getting the service status
- Returns:
Dict: Service status
- Parameters:
service_name (string) –
Example request:
GET /engines/{service_name}/status HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "serviceName": "string", "status": "Pending", "message": "string", "ready": true, "schedulable": true, "expectedReplicas": 1 }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- GET /engines/#
Get Available Inference Engine Services
Get all available inference engine services
- Args:
- db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional):
MongoDB Connection. Defaults to Depends(get_db).
- Raises:
HTTPException: 500 Internal Server Error if there is an error getting the services
- Returns:
list : List of available services
Example request:
GET /engines/ HTTP/1.1 Host: example.com
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
- POST /engines/#
Create Inference Engine Service
Create an inference engine service
- Args:
service (CreateInferenceEngineService): Service details k8s_client (ApiClient, optional): K8S client. Defaults to Depends(get_k8s_client). db (Tuple[AsyncIOMotorDatabase, AsyncIOMotorClient], optional): MongoDB connection.
Defaults to Depends(get_db).
user (TokenData, optional): User details. Defaults to Depends(get_current_user).
- Raises:
HTTPException: 500 Internal Server Error if there is an error creating the service HTTPException: 500 Internal Server Error if the API has no access to the K8S cluster HTTPException: 500 Internal Server Error if there is an error creating the service in the DB HTTPException: 422 Unprocessable Entity if the service already exists HTTPException: 422 Unprocessable Entity if the namespace is not set
- Returns:
Dict: Service details
Example request:
POST /engines/ HTTP/1.1 Host: example.com Content-Type: application/json { "modelId": "string", "imageUri": "string", "containerPort": 1, "env": {}, "numGpus": 1.0 }
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "modelId": "string", "imageUri": "string", "containerPort": 1, "env": {}, "numGpus": 1.0, "_id": "string", "inferenceUrl": "string", "ownerId": "string", "serviceName": "string", "created": "2024-03-05T02:54:36.571224", "lastModified": "2024-03-05T02:54:36.571224", "host": "string", "path": "string", "protocol": "string", "backend": "knative" }
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- POST /engines/{service_name}/restore#
Restore Inference Engine Service
Restore a deleted service (i.e someone accidently removed the deployment). This will do the following: 1. Grab information about the service from the database 2. Call the delete endpoint to delete the service 3. Call the create endpoint to create the service using the information from the database
TODO: Refactor so that I don’t have to repeat code. Preferably factor out stuff into a controller submodule (split up the code for adding to mongodb and k8s) to allow router to simply compose functions together for better reusability of code
- Parameters:
service_name (string) –
- Status Codes:
200 OK –
Successful Response
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
Validation Error
Example response:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json { "detail": [ { "loc": [ "string", 1 ], "msg": "string", "type": "string" } ] }
- DELETE /engines/admin/clear#
Wipe Orphaned Services
- Status Codes:
204 No Content – Successful Response