Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix in SageMaker SDK #714

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ private SageMaker(Builder builder) {
s3 = builder.s3;
iam = builder.iam;
model = builder.model;
modelName = model.getName();
if (builder.modelName != null) {
modelName = builder.modelName;
} else {
modelName = model.getName();
}
bucketName = builder.bucketName;
bucketPath = builder.bucketPath;
executionRole = builder.executionRole;
Expand Down Expand Up @@ -455,6 +459,7 @@ public static final class Builder {
String containerImage;
String endpointConfigName;
String endpointName;
String modelName;
String instanceType = "ml.m4.xlarge";
int instanceCount = 1;
SageMakerClient sageMaker;
Expand Down Expand Up @@ -555,6 +560,19 @@ public Builder optEndpointName(String endpointName) {
return this;
}

/**
* Sets the optional model name to create.
*
* <p>If {@code modelName} is not set, model name will be used as model name.
*
* @param modelName the model name to create
* @return the builder
*/
public Builder optModelName(String modelName) {
this.modelName = modelName;
return this;
}

/**
* Sets the optional instance type to launch the endpoint.
*
Expand Down Expand Up @@ -658,10 +676,10 @@ public SageMaker build() {
bucketPath = bucketPath.substring(1);
}
if (endpointConfigName == null) {
endpointConfigName = model.getName();
endpointConfigName = modelName == null ? model.getName() : modelName;
}
if (endpointName == null) {
endpointName = model.getName();
endpointName = modelName == null ? model.getName() : modelName;
}

return new SageMaker(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void testDeployModel() throws IOException, ModelException {
SageMaker.builder()
.setModel(model)
.optBucketName("djl-sm-test")
.optModelName("resnet")
.optContainerImage("125045733377.dkr.ecr.us-east-1.amazonaws.com/djl")
.optExecutionRole(
"arn:aws:iam::125045733377:role/service-role/DJLSageMaker-ExecutionRole-20210213T1027050")
Expand Down