Skip to content

Commit

Permalink
feat(client-sagemaker-metrics): This release introduces support for t…
Browse files Browse the repository at this point in the history
…he SageMaker Metrics BatchGetMetrics API.
  • Loading branch information
awstools committed Sep 20, 2024
1 parent a39132c commit 5b6c0db
Show file tree
Hide file tree
Showing 9 changed files with 733 additions and 16 deletions.
22 changes: 15 additions & 7 deletions clients/client-sagemaker-metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ using your favorite package manager:

The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the `SageMakerMetricsClient` and
the commands you need, for example `BatchPutMetricsCommand`:
the commands you need, for example `BatchGetMetricsCommand`:

```js
// ES5 example
const { SageMakerMetricsClient, BatchPutMetricsCommand } = require("@aws-sdk/client-sagemaker-metrics");
const { SageMakerMetricsClient, BatchGetMetricsCommand } = require("@aws-sdk/client-sagemaker-metrics");
```

```ts
// ES6+ example
import { SageMakerMetricsClient, BatchPutMetricsCommand } from "@aws-sdk/client-sagemaker-metrics";
import { SageMakerMetricsClient, BatchGetMetricsCommand } from "@aws-sdk/client-sagemaker-metrics";
```

### Usage
Expand All @@ -59,7 +59,7 @@ const client = new SageMakerMetricsClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new BatchPutMetricsCommand(params);
const command = new BatchGetMetricsCommand(params);
```

#### Async/await
Expand Down Expand Up @@ -138,15 +138,15 @@ const client = new AWS.SageMakerMetrics({ region: "REGION" });

// async/await.
try {
const data = await client.batchPutMetrics(params);
const data = await client.batchGetMetrics(params);
// process data.
} catch (error) {
// error handling.
}

// Promises.
client
.batchPutMetrics(params)
.batchGetMetrics(params)
.then((data) => {
// process data.
})
Expand All @@ -155,7 +155,7 @@ client
});

// callbacks.
client.batchPutMetrics(params, (err, data) => {
client.batchGetMetrics(params, (err, data) => {
// process err and data.
});
```
Expand Down Expand Up @@ -211,6 +211,14 @@ see LICENSE for more information.

## Client Commands (Operations List)

<details>
<summary>
BatchGetMetrics
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sagemaker-metrics/command/BatchGetMetricsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sagemaker-metrics/Interface/BatchGetMetricsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sagemaker-metrics/Interface/BatchGetMetricsCommandOutput/)

</details>
<details>
<summary>
BatchPutMetrics
Expand Down
20 changes: 20 additions & 0 deletions clients/client-sagemaker-metrics/src/SageMakerMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import { createAggregatedClient } from "@smithy/smithy-client";
import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";

import {
BatchGetMetricsCommand,
BatchGetMetricsCommandInput,
BatchGetMetricsCommandOutput,
} from "./commands/BatchGetMetricsCommand";
import {
BatchPutMetricsCommand,
BatchPutMetricsCommandInput,
Expand All @@ -10,10 +15,25 @@ import {
import { SageMakerMetricsClient, SageMakerMetricsClientConfig } from "./SageMakerMetricsClient";

const commands = {
BatchGetMetricsCommand,
BatchPutMetricsCommand,
};

export interface SageMakerMetrics {
/**
* @see {@link BatchGetMetricsCommand}
*/
batchGetMetrics(
args: BatchGetMetricsCommandInput,
options?: __HttpHandlerOptions
): Promise<BatchGetMetricsCommandOutput>;
batchGetMetrics(args: BatchGetMetricsCommandInput, cb: (err: any, data?: BatchGetMetricsCommandOutput) => void): void;
batchGetMetrics(
args: BatchGetMetricsCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: BatchGetMetricsCommandOutput) => void
): void;

/**
* @see {@link BatchPutMetricsCommand}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
HttpAuthSchemeResolvedConfig,
resolveHttpAuthSchemeConfig,
} from "./auth/httpAuthSchemeProvider";
import { BatchGetMetricsCommandInput, BatchGetMetricsCommandOutput } from "./commands/BatchGetMetricsCommand";
import { BatchPutMetricsCommandInput, BatchPutMetricsCommandOutput } from "./commands/BatchPutMetricsCommand";
import {
ClientInputEndpointParameters,
Expand All @@ -68,12 +69,12 @@ export { __Client };
/**
* @public
*/
export type ServiceInputTypes = BatchPutMetricsCommandInput;
export type ServiceInputTypes = BatchGetMetricsCommandInput | BatchPutMetricsCommandInput;

/**
* @public
*/
export type ServiceOutputTypes = BatchPutMetricsCommandOutput;
export type ServiceOutputTypes = BatchGetMetricsCommandOutput | BatchPutMetricsCommandOutput;

/**
* @public
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { commonParams } from "../endpoint/EndpointParameters";
import { BatchGetMetricsRequest, BatchGetMetricsResponse } from "../models/models_0";
import { de_BatchGetMetricsCommand, se_BatchGetMetricsCommand } from "../protocols/Aws_restJson1";
import { SageMakerMetricsClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../SageMakerMetricsClient";

/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link BatchGetMetricsCommand}.
*/
export interface BatchGetMetricsCommandInput extends BatchGetMetricsRequest {}
/**
* @public
*
* The output of {@link BatchGetMetricsCommand}.
*/
export interface BatchGetMetricsCommandOutput extends BatchGetMetricsResponse, __MetadataBearer {}

/**
* <p>Used to retrieve training metrics from SageMaker.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { SageMakerMetricsClient, BatchGetMetricsCommand } from "@aws-sdk/client-sagemaker-metrics"; // ES Modules import
* // const { SageMakerMetricsClient, BatchGetMetricsCommand } = require("@aws-sdk/client-sagemaker-metrics"); // CommonJS import
* const client = new SageMakerMetricsClient(config);
* const input = { // BatchGetMetricsRequest
* MetricQueries: [ // MetricQueryList // required
* { // MetricQuery
* MetricName: "STRING_VALUE", // required
* ResourceArn: "STRING_VALUE", // required
* MetricStat: "Min" || "Max" || "Avg" || "Count" || "StdDev" || "Last", // required
* Period: "OneMinute" || "FiveMinute" || "OneHour" || "IterationNumber", // required
* XAxisType: "IterationNumber" || "Timestamp", // required
* Start: Number("long"),
* End: Number("long"),
* },
* ],
* };
* const command = new BatchGetMetricsCommand(input);
* const response = await client.send(command);
* // { // BatchGetMetricsResponse
* // MetricQueryResults: [ // MetricQueryResultList
* // { // MetricQueryResult
* // Status: "Complete" || "Truncated" || "InternalError" || "ValidationError", // required
* // Message: "STRING_VALUE",
* // XAxisValues: [ // XAxisValues // required
* // Number("long"),
* // ],
* // MetricValues: [ // MetricValues // required
* // Number("double"),
* // ],
* // },
* // ],
* // };
*
* ```
*
* @param BatchGetMetricsCommandInput - {@link BatchGetMetricsCommandInput}
* @returns {@link BatchGetMetricsCommandOutput}
* @see {@link BatchGetMetricsCommandInput} for command's `input` shape.
* @see {@link BatchGetMetricsCommandOutput} for command's `response` shape.
* @see {@link SageMakerMetricsClientResolvedConfig | config} for SageMakerMetricsClient's `config` shape.
*
* @throws {@link SageMakerMetricsServiceException}
* <p>Base exception class for all service exceptions from SageMakerMetrics service.</p>
*
* @public
*/
export class BatchGetMetricsCommand extends $Command
.classBuilder<
BatchGetMetricsCommandInput,
BatchGetMetricsCommandOutput,
SageMakerMetricsClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: SageMakerMetricsClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("SageMakerMetricsService", "BatchGetMetrics", {})
.n("SageMakerMetricsClient", "BatchGetMetricsCommand")
.f(void 0, void 0)
.ser(se_BatchGetMetricsCommand)
.de(de_BatchGetMetricsCommand)
.build() {
/** @internal type navigation helper, not in runtime. */
protected declare static __types: {
api: {
input: BatchGetMetricsRequest;
output: BatchGetMetricsResponse;
};
sdk: {
input: BatchGetMetricsCommandInput;
output: BatchGetMetricsCommandOutput;
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export interface BatchPutMetricsCommandInput extends BatchPutMetricsRequest {}
export interface BatchPutMetricsCommandOutput extends BatchPutMetricsResponse, __MetadataBearer {}

/**
* <p>Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio and
* retrieved with the <code>GetMetrics</code> API.
* <p>Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio.
* </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
1 change: 1 addition & 0 deletions clients/client-sagemaker-metrics/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// smithy-typescript generated code
export * from "./BatchGetMetricsCommand";
export * from "./BatchPutMetricsCommand";
Loading

0 comments on commit 5b6c0db

Please sign in to comment.