22
22
import queue
23
23
24
24
import dateutil .tz
25
- from botocore .config import Config
26
-
27
25
28
26
METRICS_DIR = os .environ .get ("SAGEMAKER_METRICS_DIRECTORY" , "." )
29
27
METRIC_TS_LOWER_BOUND_TO_NOW = 1209600 # on seconds
@@ -216,8 +214,7 @@ def __init__(self, resource_arn, sagemaker_session) -> None:
216
214
AWS services needed. If not specified, one is created using the
217
215
default AWS configuration chain.
218
216
"""
219
- self ._get_metrics_client (sagemaker_session )
220
- self .sink = _SyncMetricsSink (resource_arn , self .metrics_client )
217
+ self .sink = _SyncMetricsSink (resource_arn , sagemaker_session .sagemaker_metrics_client )
221
218
222
219
def log_metric (self , metric_name , value , timestamp = None , step = None ):
223
220
"""Sends a metric to metrics service."""
@@ -237,18 +234,6 @@ def close(self):
237
234
"""Close the metrics object."""
238
235
self .sink .close ()
239
236
240
- def _get_metrics_client (self , sagemaker_session ):
241
- """Return self"""
242
-
243
- # TODO move this client instantiation into Session
244
- config = Config (retries = {"max_attempts" : 10 , "mode" : "adaptive" })
245
- stage = "prod"
246
- region = sagemaker_session .boto_session .region_name
247
- endpoint = f"https://training-metrics.{ stage } .{ region } .ml-platform.aws.a2z.com"
248
- self .metrics_client = sagemaker_session .boto_session .client (
249
- "sagemaker-metrics" , config = config , endpoint_url = endpoint
250
- )
251
-
252
237
253
238
class _SyncMetricsSink (object ):
254
239
"""Collects metrics and sends them directly to metrics service."""
0 commit comments