Skip to content

Commit efa3b83

Browse files
Aditi2424adishaa
andauthored
Support BatchGetMetrics from sagemaker-metrics (#207)
* Support BatchGetMetrics from sagemaker-metrics * Change resoure type and method type * Update count --------- Co-authored-by: Aditi Sharma <[email protected]>
1 parent 9d23088 commit efa3b83

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

src/sagemaker_core/main/resources.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16518,6 +16518,7 @@ def wrapper(*args, **kwargs):
1651816518
"s3_data_source": {
1651916519
"s3_uri": {"type": "string"},
1652016520
"s3_data_type": {"type": "string"},
16521+
"manifest_s3_uri": {"type": "string"},
1652116522
}
1652216523
}
1652316524
},
@@ -27953,6 +27954,55 @@ def batch_put_metrics(
2795327954
response = client.batch_put_metrics(**operation_input_args)
2795427955
logger.debug(f"Response: {response}")
2795527956

27957+
@classmethod
27958+
@Base.add_validate_call
27959+
def batch_get_metrics(
27960+
cls,
27961+
metric_queries: List[MetricQuery],
27962+
session: Optional[Session] = None,
27963+
region: Optional[str] = None,
27964+
) -> Optional[BatchGetMetricsResponse]:
27965+
"""
27966+
Used to retrieve training metrics from SageMaker.
27967+
27968+
Parameters:
27969+
metric_queries: Queries made to retrieve training metrics from SageMaker.
27970+
session: Boto3 session.
27971+
region: Region name.
27972+
27973+
Returns:
27974+
BatchGetMetricsResponse
27975+
27976+
Raises:
27977+
botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
27978+
The error message and error code can be parsed from the exception as follows:
27979+
```
27980+
try:
27981+
# AWS service call here
27982+
except botocore.exceptions.ClientError as e:
27983+
error_message = e.response['Error']['Message']
27984+
error_code = e.response['Error']['Code']
27985+
```
27986+
"""
27987+
27988+
operation_input_args = {
27989+
"MetricQueries": metric_queries,
27990+
}
27991+
# serialize the input request
27992+
operation_input_args = serialize(operation_input_args)
27993+
logger.debug(f"Serialized input request: {operation_input_args}")
27994+
27995+
client = Base.get_sagemaker_client(
27996+
session=session, region_name=region, service_name="sagemaker-metrics"
27997+
)
27998+
27999+
logger.debug(f"Calling batch_get_metrics API")
28000+
response = client.batch_get_metrics(**operation_input_args)
28001+
logger.debug(f"Response: {response}")
28002+
28003+
transformed_response = transform(response, "BatchGetMetricsResponse")
28004+
return BatchGetMetricsResponse(**transformed_response)
28005+
2795628006

2795728007
class UserProfile(Base):
2795828008
"""

src/sagemaker_core/main/shapes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,18 @@ class MetricQueryResult(Base):
406406
message: Optional[str] = Unassigned()
407407

408408

409+
class BatchGetMetricsResponse(Base):
410+
"""
411+
BatchGetMetricsResponse
412+
413+
Attributes
414+
----------------------
415+
metric_query_results: The results of a query to retrieve training metrics from SageMaker.
416+
"""
417+
418+
metric_query_results: Optional[List[MetricQueryResult]] = Unassigned()
419+
420+
409421
class BatchPutMetricsError(Base):
410422
"""
411423
BatchPutMetricsError

src/sagemaker_core/tools/additional_operations.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@
169169
"return_type": "None",
170170
"method_type": "object",
171171
"service_name": "sagemaker-metrics"
172+
},
173+
"BatchGetMetrics": {
174+
"operation_name": "BatchGetMetrics",
175+
"resource_name": "TrialComponent",
176+
"method_name": "batch_get_metrics",
177+
"return_type": "BatchGetMetricsResponse",
178+
"method_type": "class",
179+
"service_name": "sagemaker-metrics"
172180
}
173181
},
174182
"HubContent": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"SupportedAPIs": 338, "UnsupportedAPIs": 6}
1+
{"SupportedAPIs": 339, "UnsupportedAPIs": 5}

0 commit comments

Comments
 (0)