Skip to content

Commit

Permalink
Fix grpc deprecation breakages
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Hill <[email protected]>
  • Loading branch information
njhill committed Oct 25, 2023
1 parent 76b7b5b commit 959f729
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ public static <T extends AbstractStub<T>> T forModel(T stub, String... modelIds)
headers.put(MODEL_ID_META_KEY, modelId);
}
headers.put(CUST_HEADER_KEY, "custom-value");
return MetadataUtils.attachHeaders(stub, headers);
return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(headers));
}

public static <T extends AbstractStub<T>> T forVModel(T stub, String... vmodelIds) {
Metadata headers = new Metadata();
for (String modelId : vmodelIds) {
headers.put(VMODEL_ID_META_KEY, modelId);
}
return MetadataUtils.attachHeaders(stub, headers);
return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(headers));
}

// default KV store to test is etcd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static <T extends AbstractStub<T>> T forModel(T stub, String... modelIds)
headers.put(MODEL_ID_META_KEY, modelId);
}
headers.put(CUST_HEADER_KEY, "custom-value");
return MetadataUtils.attachHeaders(stub, headers);
return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(headers));
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static <T extends AbstractStub<T>> T forModel(T stub, String... modelIds)
headers.put(MODEL_ID_META_KEY, modelId);
}
headers.put(CUST_HEADER_KEY, "custom-value");
return MetadataUtils.attachHeaders(stub, headers);
return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(headers));
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public void headerLoggingTest() throws Exception {
// We'll make sure this one *isn't* logged since it wasn't included in the config
headers.put(unloggedHeader, "my-unlogged-value");

PredictResponse response = MetadataUtils.attachHeaders(useModels, headers).predict(req);
PredictResponse response = useModels.withInterceptors(
MetadataUtils.newAttachHeadersInterceptor(headers)).predict(req);
assertEquals("classification for predict me! by model myModel",
response.getResults(0).getCategory());

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/ibm/watson/modelmesh/VModelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,6 @@ private static VModelStatusInfo clearTargetCopyInfo(VModelStatusInfo vmsi) {
public static <T extends AbstractStub<T>> T forVModel(T stub, String modelId) {
Metadata headers = new Metadata();
headers.put(VMODEL_ID_META_KEY, modelId);
return MetadataUtils.attachHeaders(stub, headers);
return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(headers));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void main(String[] args) {
public static <T extends AbstractStub<T>> T forModel(T stub, String modelId) {
Metadata headers = new Metadata();
headers.put(MODEL_ID_META_KEY, modelId);
return MetadataUtils.attachHeaders(stub, headers);
return stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(headers));
}

}

0 comments on commit 959f729

Please sign in to comment.