Used to retrieve training metrics from SageMaker.
+ * @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} + *Base exception class for all service exceptions from SageMakerMetrics service.
+ * + * @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; + }; + }; +} diff --git a/clients/client-sagemaker-metrics/src/commands/BatchPutMetricsCommand.ts b/clients/client-sagemaker-metrics/src/commands/BatchPutMetricsCommand.ts index ec89c3d9901e..73b359fb8008 100644 --- a/clients/client-sagemaker-metrics/src/commands/BatchPutMetricsCommand.ts +++ b/clients/client-sagemaker-metrics/src/commands/BatchPutMetricsCommand.ts @@ -28,8 +28,7 @@ export interface BatchPutMetricsCommandInput extends BatchPutMetricsRequest {} export interface BatchPutMetricsCommandOutput extends BatchPutMetricsResponse, __MetadataBearer {} /** - *Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio and
- * retrieved with the GetMetrics
API.
+ *
Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio. *
* @example * Use a bare-bones client and the command you need to make an API call. diff --git a/clients/client-sagemaker-metrics/src/commands/index.ts b/clients/client-sagemaker-metrics/src/commands/index.ts index 593de5f9f754..b9d5c0499779 100644 --- a/clients/client-sagemaker-metrics/src/commands/index.ts +++ b/clients/client-sagemaker-metrics/src/commands/index.ts @@ -1,2 +1,3 @@ // smithy-typescript generated code +export * from "./BatchGetMetricsCommand"; export * from "./BatchPutMetricsCommand"; diff --git a/clients/client-sagemaker-metrics/src/models/models_0.ts b/clients/client-sagemaker-metrics/src/models/models_0.ts index d868d93ae86a..c3127acc5a10 100644 --- a/clients/client-sagemaker-metrics/src/models/models_0.ts +++ b/clients/client-sagemaker-metrics/src/models/models_0.ts @@ -1,4 +1,168 @@ // smithy-typescript generated code +/** + * @public + * @enum + */ +export const MetricStatistic = { + AVG: "Avg", + COUNT: "Count", + LAST: "Last", + MAX: "Max", + MIN: "Min", + STD_DEV: "StdDev", +} as const; + +/** + * @public + */ +export type MetricStatistic = (typeof MetricStatistic)[keyof typeof MetricStatistic]; + +/** + * @public + * @enum + */ +export const Period = { + FIVE_MINUTE: "FiveMinute", + ITERATION_NUMBER: "IterationNumber", + ONE_HOUR: "OneHour", + ONE_MINUTE: "OneMinute", +} as const; + +/** + * @public + */ +export type Period = (typeof Period)[keyof typeof Period]; + +/** + * @public + * @enum + */ +export const XAxisType = { + ITERATION_NUMBER: "IterationNumber", + TIMESTAMP: "Timestamp", +} as const; + +/** + * @public + */ +export type XAxisType = (typeof XAxisType)[keyof typeof XAxisType]; + +/** + *Specifies a query to retrieve training metrics from SageMaker.
+ * @public + */ +export interface MetricQuery { + /** + *The name of the metric to retrieve.
+ * @public + */ + MetricName: string | undefined; + + /** + *The ARN of the SageMaker resource to retrieve metrics for.
+ * @public + */ + ResourceArn: string | undefined; + + /** + *The metrics stat type of metrics to retrieve.
+ * @public + */ + MetricStat: MetricStatistic | undefined; + + /** + *The time period of metrics to retrieve.
+ * @public + */ + Period: Period | undefined; + + /** + *The x-axis type of metrics to retrieve.
+ * @public + */ + XAxisType: XAxisType | undefined; + + /** + *The start time of metrics to retrieve.
+ * @public + */ + Start?: number; + + /** + *The end time of metrics to retrieve.
+ * @public + */ + End?: number; +} + +/** + * @public + */ +export interface BatchGetMetricsRequest { + /** + *Queries made to retrieve training metrics from SageMaker.
+ * @public + */ + MetricQueries: MetricQuery[] | undefined; +} + +/** + * @public + * @enum + */ +export const MetricQueryResultStatus = { + COMPLETE: "Complete", + INTERNAL_ERROR: "InternalError", + TRUNCATED: "Truncated", + VALIDATION_ERROR: "ValidationError", +} as const; + +/** + * @public + */ +export type MetricQueryResultStatus = (typeof MetricQueryResultStatus)[keyof typeof MetricQueryResultStatus]; + +/** + *The result of a query to retrieve training metrics from SageMaker.
+ * @public + */ +export interface MetricQueryResult { + /** + *The status of the metric query.
+ * @public + */ + Status: MetricQueryResultStatus | undefined; + + /** + *A message describing the status of the metric query.
+ * @public + */ + Message?: string; + + /** + *The values for the x-axis of the metrics.
+ * @public + */ + XAxisValues: number[] | undefined; + + /** + *The metric values retrieved by the query.
+ * @public + */ + MetricValues: number[] | undefined; +} + +/** + * @public + */ +export interface BatchGetMetricsResponse { + /** + *The results of a query to retrieve training metrics from SageMaker.
+ * @public + */ + MetricQueryResults?: MetricQueryResult[]; +} + /** *The raw metric data to associate with the resource.
* @public @@ -35,7 +199,7 @@ export interface RawMetricData { */ export interface BatchPutMetricsRequest { /** - *The name of the Trial Component to associate with the metrics.
+ *The name of the Trial Component to associate with the metrics. The Trial Component name must be entirely lowercase.
* @public */ TrialComponentName: string | undefined; diff --git a/clients/client-sagemaker-metrics/src/protocols/Aws_restJson1.ts b/clients/client-sagemaker-metrics/src/protocols/Aws_restJson1.ts index 236aa51fb816..947bfb507a16 100644 --- a/clients/client-sagemaker-metrics/src/protocols/Aws_restJson1.ts +++ b/clients/client-sagemaker-metrics/src/protocols/Aws_restJson1.ts @@ -7,6 +7,8 @@ import { collectBody, expectNonNull as __expectNonNull, expectObject as __expectObject, + expectString as __expectString, + limitedParseDouble as __limitedParseDouble, map, serializeFloat as __serializeFloat, take, @@ -18,10 +20,33 @@ import { SerdeContext as __SerdeContext, } from "@smithy/types"; +import { BatchGetMetricsCommandInput, BatchGetMetricsCommandOutput } from "../commands/BatchGetMetricsCommand"; import { BatchPutMetricsCommandInput, BatchPutMetricsCommandOutput } from "../commands/BatchPutMetricsCommand"; -import { RawMetricData } from "../models/models_0"; +import { MetricQuery, MetricQueryResult, RawMetricData } from "../models/models_0"; import { SageMakerMetricsServiceException as __BaseException } from "../models/SageMakerMetricsServiceException"; +/** + * serializeAws_restJson1BatchGetMetricsCommand + */ +export const se_BatchGetMetricsCommand = async ( + input: BatchGetMetricsCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const b = rb(input, context); + const headers: any = { + "content-type": "application/json", + }; + b.bp("/BatchGetMetrics"); + let body: any; + body = JSON.stringify( + take(input, { + MetricQueries: (_) => _json(_), + }) + ); + b.m("POST").h(headers).b(body); + return b.build(); +}; + /** * serializeAws_restJson1BatchPutMetricsCommand */ @@ -45,6 +70,27 @@ export const se_BatchPutMetricsCommand = async ( return b.build(); }; +/** + * deserializeAws_restJson1BatchGetMetricsCommand + */ +export const de_BatchGetMetricsCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): PromiseUsed to retrieve training metrics from SageMaker.
", + "smithy.api#http": { + "method": "POST", + "uri": "/BatchGetMetrics", + "code": 200 + } + } + }, + "com.amazonaws.sagemakermetrics#BatchGetMetricsRequest": { + "type": "structure", + "members": { + "MetricQueries": { + "target": "com.amazonaws.sagemakermetrics#MetricQueryList", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "Queries made to retrieve training metrics from SageMaker.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.sagemakermetrics#BatchGetMetricsResponse": { + "type": "structure", + "members": { + "MetricQueryResults": { + "target": "com.amazonaws.sagemakermetrics#MetricQueryResultList", + "traits": { + "smithy.api#documentation": "The results of a query to retrieve training metrics from SageMaker.
" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, "com.amazonaws.sagemakermetrics#BatchPutMetrics": { "type": "operation", "input": { @@ -38,7 +85,7 @@ "target": "com.amazonaws.sagemakermetrics#BatchPutMetricsResponse" }, "traits": { - "smithy.api#documentation": "Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio and\n retrieved with the GetMetrics
API.\n
Used to ingest training metrics into SageMaker. These metrics can be visualized in SageMaker Studio.\n
", "smithy.api#http": { "method": "PUT", "uri": "/BatchPutMetrics", @@ -85,7 +132,7 @@ "target": "com.amazonaws.sagemakermetrics#ExperimentEntityName", "traits": { "smithy.api#clientOptional": {}, - "smithy.api#documentation": "The name of the Trial Component to associate with the metrics.
", + "smithy.api#documentation": "The name of the Trial Component to associate with the metrics. The Trial Component name must be entirely lowercase.
", "smithy.api#required": {} } }, @@ -126,12 +173,25 @@ "min": 1, "max": 120 }, - "smithy.api#pattern": "^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,119}$" + "smithy.api#pattern": "^[a-z0-9](-*[a-z0-9]){0,119}$" } }, "com.amazonaws.sagemakermetrics#Integer": { "type": "integer" }, + "com.amazonaws.sagemakermetrics#Long": { + "type": "long" + }, + "com.amazonaws.sagemakermetrics#Message": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 0, + "max": 2048 + }, + "smithy.api#pattern": ".*" + } + }, "com.amazonaws.sagemakermetrics#MetricName": { "type": "string", "traits": { @@ -142,6 +202,233 @@ "smithy.api#pattern": "^.+$" } }, + "com.amazonaws.sagemakermetrics#MetricQuery": { + "type": "structure", + "members": { + "MetricName": { + "target": "com.amazonaws.sagemakermetrics#MetricName", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The name of the metric to retrieve.
", + "smithy.api#required": {} + } + }, + "ResourceArn": { + "target": "com.amazonaws.sagemakermetrics#SageMakerResourceArn", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The ARN of the SageMaker resource to retrieve metrics for.
", + "smithy.api#required": {} + } + }, + "MetricStat": { + "target": "com.amazonaws.sagemakermetrics#MetricStatistic", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The metrics stat type of metrics to retrieve.
", + "smithy.api#required": {} + } + }, + "Period": { + "target": "com.amazonaws.sagemakermetrics#Period", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The time period of metrics to retrieve.
", + "smithy.api#required": {} + } + }, + "XAxisType": { + "target": "com.amazonaws.sagemakermetrics#XAxisType", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The x-axis type of metrics to retrieve.
", + "smithy.api#required": {} + } + }, + "Start": { + "target": "com.amazonaws.sagemakermetrics#Long", + "traits": { + "smithy.api#documentation": "The start time of metrics to retrieve.
" + } + }, + "End": { + "target": "com.amazonaws.sagemakermetrics#Long", + "traits": { + "smithy.api#documentation": "The end time of metrics to retrieve.
" + } + } + }, + "traits": { + "smithy.api#documentation": "Specifies a query to retrieve training metrics from SageMaker.
" + } + }, + "com.amazonaws.sagemakermetrics#MetricQueryList": { + "type": "list", + "member": { + "target": "com.amazonaws.sagemakermetrics#MetricQuery" + }, + "traits": { + "smithy.api#length": { + "min": 1, + "max": 100 + } + } + }, + "com.amazonaws.sagemakermetrics#MetricQueryResult": { + "type": "structure", + "members": { + "Status": { + "target": "com.amazonaws.sagemakermetrics#MetricQueryResultStatus", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The status of the metric query.
", + "smithy.api#required": {} + } + }, + "Message": { + "target": "com.amazonaws.sagemakermetrics#Message", + "traits": { + "smithy.api#documentation": "A message describing the status of the metric query.
" + } + }, + "XAxisValues": { + "target": "com.amazonaws.sagemakermetrics#XAxisValues", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The values for the x-axis of the metrics.
", + "smithy.api#required": {} + } + }, + "MetricValues": { + "target": "com.amazonaws.sagemakermetrics#MetricValues", + "traits": { + "smithy.api#clientOptional": {}, + "smithy.api#documentation": "The metric values retrieved by the query.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "The result of a query to retrieve training metrics from SageMaker.
" + } + }, + "com.amazonaws.sagemakermetrics#MetricQueryResultList": { + "type": "list", + "member": { + "target": "com.amazonaws.sagemakermetrics#MetricQueryResult" + }, + "traits": { + "smithy.api#length": { + "min": 1, + "max": 100 + } + } + }, + "com.amazonaws.sagemakermetrics#MetricQueryResultStatus": { + "type": "enum", + "members": { + "COMPLETE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Complete" + } + }, + "TRUNCATED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Truncated" + } + }, + "INTERNAL_ERROR": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "InternalError" + } + }, + "VALIDATION_ERROR": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ValidationError" + } + } + } + }, + "com.amazonaws.sagemakermetrics#MetricStatistic": { + "type": "enum", + "members": { + "MIN": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Min" + } + }, + "MAX": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Max" + } + }, + "AVG": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Avg" + } + }, + "COUNT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Count" + } + }, + "STD_DEV": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "StdDev" + } + }, + "LAST": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Last" + } + } + } + }, + "com.amazonaws.sagemakermetrics#MetricValues": { + "type": "list", + "member": { + "target": "com.amazonaws.sagemakermetrics#Double" + } + }, + "com.amazonaws.sagemakermetrics#Period": { + "type": "enum", + "members": { + "ONE_MINUTE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "OneMinute" + } + }, + "FIVE_MINUTE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "FiveMinute" + } + }, + "ONE_HOUR": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "OneHour" + } + }, + "ITERATION_NUMBER": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "IterationNumber" + } + } + } + }, "com.amazonaws.sagemakermetrics#PutMetricsErrorCode": { "type": "enum", "members": { @@ -225,6 +512,9 @@ "type": "service", "version": "2022-09-30", "operations": [ + { + "target": "com.amazonaws.sagemakermetrics#BatchGetMetrics" + }, { "target": "com.amazonaws.sagemakermetrics#BatchPutMetrics" } @@ -909,6 +1199,16 @@ } } }, + "com.amazonaws.sagemakermetrics#SageMakerResourceArn": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 0, + "max": 2048 + }, + "smithy.api#pattern": "^arn:aws[a-z\\-]*:sagemaker:[a-z0-9\\-]*:[0-9]{12}:[a-z\\-].*/" + } + }, "com.amazonaws.sagemakermetrics#Step": { "type": "integer", "traits": { @@ -919,6 +1219,29 @@ }, "com.amazonaws.sagemakermetrics#Timestamp": { "type": "timestamp" + }, + "com.amazonaws.sagemakermetrics#XAxisType": { + "type": "enum", + "members": { + "ITERATION_NUMBER": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "IterationNumber" + } + }, + "TIMESTAMP": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Timestamp" + } + } + } + }, + "com.amazonaws.sagemakermetrics#XAxisValues": { + "type": "list", + "member": { + "target": "com.amazonaws.sagemakermetrics#Long" + } } } }