Skip to content

Commit cfae9a3

Browse files
danabensqidewenwhen
authored andcommitted
use metrics client provided by session (aws#754)
1 parent 599aadb commit cfae9a3

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/sagemaker/experiments/_metrics.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import queue
2323

2424
import dateutil.tz
25-
from botocore.config import Config
26-
2725

2826
METRICS_DIR = os.environ.get("SAGEMAKER_METRICS_DIRECTORY", ".")
2927
METRIC_TS_LOWER_BOUND_TO_NOW = 1209600 # on seconds
@@ -216,8 +214,7 @@ def __init__(self, resource_arn, sagemaker_session) -> None:
216214
AWS services needed. If not specified, one is created using the
217215
default AWS configuration chain.
218216
"""
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)
221218

222219
def log_metric(self, metric_name, value, timestamp=None, step=None):
223220
"""Sends a metric to metrics service."""
@@ -237,18 +234,6 @@ def close(self):
237234
"""Close the metrics object."""
238235
self.sink.close()
239236

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-
252237

253238
class _SyncMetricsSink(object):
254239
"""Collects metrics and sends them directly to metrics service."""

0 commit comments

Comments
 (0)