use of com.aliyun.ons20190214.Client in project submarine by apache.
the class ModelManager method transferDescription.
private void transferDescription(ServeSpec spec) {
Client s3Client = new Client();
String modelUniquePath = String.format("%s-%d-%s", spec.getModelName(), spec.getModelVersion(), spec.getModelId());
String res = new String(s3Client.downloadArtifact(String.format("registry/%s/%s/%d/description.json", modelUniquePath, spec.getModelName(), spec.getModelVersion())));
JSONObject description = new JSONObject(res);
TritonModelConfig.ModelConfig.Builder modelConfig = TritonModelConfig.ModelConfig.newBuilder();
modelConfig.setPlatform("pytorch_libtorch");
JSONArray inputs = (JSONArray) description.get("input");
for (int idx = 0; idx < inputs.length(); idx++) {
JSONArray dims = (JSONArray) ((JSONObject) inputs.get(idx)).get("dims");
TritonModelConfig.ModelInput.Builder modelInput = TritonModelConfig.ModelInput.newBuilder();
modelInput.setName("INPUT__" + idx);
modelInput.setDataType(TritonModelConfig.DataType.valueOf("TYPE_FP32"));
dims.forEach(dim -> modelInput.addDims((Integer) dim));
modelConfig.addInput(modelInput);
}
JSONArray outputs = (JSONArray) description.get("output");
for (int idx = 0; idx < outputs.length(); idx++) {
JSONArray dims = (JSONArray) ((JSONObject) outputs.get(idx)).get("dims");
TritonModelConfig.ModelOutput.Builder modelOutput = TritonModelConfig.ModelOutput.newBuilder();
modelOutput.setName("OUTPUT__" + idx);
modelOutput.setDataType(TritonModelConfig.DataType.valueOf("TYPE_FP32"));
dims.forEach(dim -> modelOutput.addDims((Integer) dim));
modelConfig.addOutput(modelOutput);
}
s3Client.logArtifact(String.format("registry/%s/%s/config.pbtxt", modelUniquePath, spec.getModelName()), modelConfig.toString().getBytes());
}
Aggregations