Skip to content

Commit

Permalink
[fix] [SageMakerRuntime] empty body string when invokeEndpointAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
tan-t committed Sep 10, 2022
1 parent b319ab6 commit 09dc6e9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-SageMakerRuntime-407b0118.json
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "SageMakerRuntime",
"description": "fixed the issue that invokeEndpointAsync is not callable #4203"
}
1 change: 1 addition & 0 deletions clients/sagemakerruntime.js
Expand Up @@ -5,6 +5,7 @@ var apiLoader = AWS.apiLoader;

apiLoader.services['sagemakerruntime'] = {};
AWS.SageMakerRuntime = Service.defineService('sagemakerruntime', ['2017-05-13']);
require('../lib/services/sagemakerruntime');
Object.defineProperty(apiLoader.services['sagemakerruntime'], '2017-05-13', {
get: function get() {
var model = require('../apis/runtime.sagemaker-2017-05-13.min.json');
Expand Down
20 changes: 20 additions & 0 deletions lib/services/sagemakerruntime.js
@@ -0,0 +1,20 @@
var AWS = require('../core');

AWS.util.update(AWS.SageMakerRuntime.prototype, {
/**
* @api private
*/
setupRequestListeners: function setupRequestListeners(request) {
if (request.operation === 'invokeEndpointAsync') {
request.addListener('build', this.emptyBody);
}
},

/**
* Empty request body for async inference
* @api private
*/
emptyBody: function emptyBody(request) {
request.httpRequest.body = '';
},
});
30 changes: 30 additions & 0 deletions test/services/sagemakerruntime.spec.js
@@ -0,0 +1,30 @@
(function () {
const helpers = require('../helpers');
const { AWS, spyOn } = helpers;

return describe('SageMakerRuntime.invokeEndpointAsync', function () {
it('should call api with an empty body', async () => {
const httpClient = AWS.HttpClient.getInstance();
spyOn(httpClient, 'handleRequest').andCallFake(function (
httpReq,
httpOp,
cb,
errCb
) {
expect(httpReq.body).to.equal('');
helpers.mockHttpSuccessfulResponse(
200,
{},
JSON.stringify({ success: true }),
cb
);
});
await new AWS.SageMakerRuntime()
.invokeEndpointAsync({
InputLocation: 's3://mock',
EndpointName: 'mock',
})
.promise();
});
});
}.call(this));

0 comments on commit 09dc6e9

Please sign in to comment.