in frontend/server/src/main/java/org/pytorch/serve/openapi/OpenApiUtils.java [370:446]
private static Operation getDescribeModelOperation(boolean version) {
String operationDescription;
String operationId;
if (version) {
operationDescription =
"Provides detailed information about the specified version of a model."
+ "If \"all\" is specified as version, returns the details about all the versions of the model.";
operationId = "version_describeModel";
} else {
operationDescription =
"Provides detailed information about the default version of a model.";
operationId = "describeModel";
}
Operation operation = new Operation(operationId, operationDescription);
operation.addParameter(new PathParameter("model_name", "Name of model to describe."));
if (version) {
operation.addParameter(
new PathParameter("model_version", "Version of model to describe."));
}
Schema schema = new Schema("object");
schema.addProperty("modelName", new Schema("string", "Name of the model."), true);
schema.addProperty("modelVersion", new Schema("string", "Version of the model."), true);
schema.addProperty("modelUrl", new Schema("string", "URL of the model."), true);
schema.addProperty(
"minWorkers", new Schema("integer", "Configured minimum number of worker."), true);
schema.addProperty(
"maxWorkers", new Schema("integer", "Configured maximum number of worker."), true);
schema.addProperty("batchSize", new Schema("integer", "Configured batch size."), false);
schema.addProperty(
"maxBatchDelay",
new Schema("integer", "Configured maximum batch delay in ms."),
false);
schema.addProperty(
"status", new Schema("string", "Overall health status of the model"), true);
Schema workers = new Schema("array", "A list of active backend workers.");
Schema worker = new Schema("object");
worker.addProperty("id", new Schema("string", "Worker id"), true);
worker.addProperty("startTime", new Schema("string", "Worker start time"), true);
worker.addProperty("gpu", new Schema("boolean", "If running on GPU"), false);
Schema workerStatus = new Schema("string", "Worker status");
List<String> status = new ArrayList<>();
status.add("READY");
status.add("LOADING");
status.add("UNLOADING");
workerStatus.setEnumeration(status);
worker.addProperty("status", workerStatus, true);
workers.setItems(worker);
schema.addProperty("workers", workers, true);
Schema metrics = new Schema("object");
metrics.addProperty(
"rejectedRequests",
new Schema("integer", "Number requests has been rejected in last 10 minutes."),
true);
metrics.addProperty(
"waitingQueueSize",
new Schema("integer", "Number requests waiting in the queue."),
true);
metrics.addProperty(
"requests",
new Schema("integer", "Number requests processed in last 10 minutes."),
true);
schema.addProperty("metrics", metrics, true);
MediaType mediaType = new MediaType(HttpHeaderValues.APPLICATION_JSON.toString(), schema);
MediaType error = getErrorResponse();
operation.addResponse(new Response("200", "OK", mediaType));
operation.addResponse(
new Response("404", "Model not found or Model version not found", error));
operation.addResponse(new Response("500", "Internal Server Error", error));
return operation;
}