Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] [SageMakerRuntime] empty body string when invokeEndpointAsync
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "bugfix", | ||
"category": "SageMakerRuntime", | ||
"description": "fixed the issue that invokeEndpointAsync is not callable #4203" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = ''; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); |