12
12
# language governing permissions and limitations under the License.
13
13
from __future__ import absolute_import
14
14
15
- import time
16
15
import boto3
17
16
import os
18
17
from botocore .config import Config
23
22
get_sm_session ,
24
23
)
25
24
26
- from sagemaker .utils import repack_model
25
+ from sagemaker .utils import repack_model , unique_name_from_base
27
26
from tests .integ .sagemaker .jumpstart .constants import (
28
27
ENV_VAR_JUMPSTART_SDK_TEST_SUITE_ID ,
29
28
JUMPSTART_TAG ,
@@ -38,18 +37,14 @@ def __init__(
38
37
model_uri ,
39
38
instance_type ,
40
39
environment_variables ,
41
- suffix = time .strftime ("%Y-%m-%d-%H-%M-%S" , time .gmtime ()),
42
40
region = JUMPSTART_DEFAULT_REGION_NAME ,
43
41
boto_config = Config (retries = {"max_attempts" : 10 , "mode" : "standard" }),
44
- base_name = "jumpstart-inference-job" ,
45
42
execution_role = None ,
46
43
) -> None :
47
44
48
- self .suffix = suffix
49
45
self .test_suite_id = os .environ [ENV_VAR_JUMPSTART_SDK_TEST_SUITE_ID ]
50
46
self .region = region
51
47
self .config = boto_config
52
- self .base_name = base_name
53
48
self .execution_role = execution_role or get_sm_session ().get_caller_identity_arn ()
54
49
self .account_id = boto3 .client ("sts" ).get_caller_identity ()["Account" ]
55
50
self .image_uri = image_uri
@@ -110,41 +105,13 @@ def get_sagemaker_client(self) -> boto3.client:
110
105
return boto3 .client (service_name = "sagemaker" , config = self .config , region_name = self .region )
111
106
112
107
def get_endpoint_config_name (self ) -> str :
113
- timestamp_length = len (self .suffix )
114
- non_timestamped_name = f"{ self .base_name } -endpoint-config-"
115
-
116
- max_endpoint_config_name_length = 63
117
-
118
- if len (non_timestamped_name ) > max_endpoint_config_name_length - timestamp_length :
119
- non_timestamped_name = non_timestamped_name [
120
- : max_endpoint_config_name_length - timestamp_length
121
- ]
122
-
123
- return f"{ non_timestamped_name } { self .suffix } "
108
+ return unique_name_from_base ("endpoint-config" )
124
109
125
110
def get_endpoint_name (self ) -> str :
126
- timestamp_length = len (self .suffix )
127
- non_timestamped_name = f"{ self .base_name } -endpoint-"
128
-
129
- max_endpoint_name_length = 63
130
-
131
- if len (non_timestamped_name ) > max_endpoint_name_length - timestamp_length :
132
- non_timestamped_name = non_timestamped_name [
133
- : max_endpoint_name_length - timestamp_length
134
- ]
135
-
136
- return f"{ non_timestamped_name } { self .suffix } "
111
+ return unique_name_from_base ("endpoint" )
137
112
138
113
def get_model_name (self ) -> str :
139
- timestamp_length = len (self .suffix )
140
- non_timestamped_name = f"{ self .base_name } -model-"
141
-
142
- max_model_name_length = 63
143
-
144
- if len (non_timestamped_name ) > max_model_name_length - timestamp_length :
145
- non_timestamped_name = non_timestamped_name [: max_model_name_length - timestamp_length ]
146
-
147
- return f"{ non_timestamped_name } { self .suffix } "
114
+ return unique_name_from_base ("model" )
148
115
149
116
def create_model (self ) -> None :
150
117
self .sagemaker_client .create_model (
0 commit comments