florist.api.routes.server.job module

FastAPI routes for the job.

async change_job_status(job_id, status, request)[source]

Change job job_id to specified status.

Parameters:
  • job_id (str) – (str) The id of the job to change the status of.

  • status (JobStatus) – (JobStatus) The status to change job_id to.

  • request (Request) – (fastapi.Request) the FastAPI request object.

Return type:

JSONResponse

Returns:

(JSONResponse) If successful, returns 200. If not successful, returns response with status code 400 and body: {“error”: <error message>}

async get_job(job_id, request)[source]

Retrieve a training job by its ID.

Parameters:
  • request (Request) – (fastapi.Request) the FastAPI request object.

  • job_id (str) – (str) The ID of the job to be retrieved.

Return type:

Union[Job, JSONResponse]

Returns:

(Union[Job, JSONResponse]) The job with the given ID, or a 400 JSONResponse if it hasn’t been found.

async list_jobs_with_status(status, request)[source]

List jobs with specified status.

Fetches list of Job with max length MAX_RECORDS_TO_FETCH.

Parameters:
  • status (JobStatus) – (JobStatus) The status of jobs to query the Job DB for.

  • request (Request) – (fastapi.Request) the FastAPI request object.

Return type:

List[Job]

Returns:

(List[Dict[str, Any]]) A list where each entry is a dictionary with the attributes of a Job instance with the specified status.

async new_job(request, job=Body(Ellipsis))[source]

Create a new training job.

If calling from the REST API, it will receive the job attributes as the Request Body in raw/JSON format. See florist.api.db.entities.Job to check the list of attributes and their requirements.

Parameters:
  • request (Request) – (fastapi.Request) the FastAPI request object.

  • job (Job) – (Job) The Job instance to be saved in the database.

Return type:

Job

Returns:

(Job) The job that has been saved in the database.

Raises:

(HTTPException) status 400 if job.server_info is not None and cannot be parsed into JSON.