1818import pandas as pd
1919from botocore .exceptions import ClientError
2020
21+ from sagemaker_core .shapes import ModelAccessConfig
2122from sagemaker import payloads
2223from sagemaker .async_inference .async_inference_config import AsyncInferenceConfig
2324from sagemaker .base_deserializers import BaseDeserializer
5152 add_instance_rate_stats_to_benchmark_metrics ,
5253 deployment_config_response_data ,
5354 _deployment_config_lru_cache ,
55+ _add_model_access_configs_to_model_data_sources ,
5456)
5557from sagemaker .jumpstart .constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION , JUMPSTART_LOGGER
5658from sagemaker .jumpstart .enums import JumpStartModelType
@@ -111,7 +113,6 @@ def __init__(
111113 resources : Optional [ResourceRequirements ] = None ,
112114 config_name : Optional [str ] = None ,
113115 additional_model_data_sources : Optional [Dict [str , Any ]] = None ,
114- accept_draft_model_eula : Optional [bool ] = None ,
115116 ):
116117 """Initializes a ``JumpStartModel``.
117118
@@ -302,10 +303,6 @@ def __init__(
302303 optionally applied to the model.
303304 additional_model_data_sources (Optional[Dict[str, Any]]): Additional location
304305 of SageMaker model data (default: None).
305- accept_draft_model_eula (bool): For draft models that require a Model Access Config, specify True or
306- False to indicate whether model terms of use have been accepted.
307- The `accept_draft_model_eula` value must be explicitly defined as `True` in order to
308- accept the end-user license agreement (EULA) that some
309306 Raises:
310307 ValueError: If the model ID is not recognized by JumpStart.
311308 """
@@ -365,7 +362,6 @@ def _validate_model_id_and_type():
365362 resources = resources ,
366363 config_name = config_name ,
367364 additional_model_data_sources = additional_model_data_sources ,
368- accept_draft_model_eula = accept_draft_model_eula
369365 )
370366
371367 self .orig_predictor_cls = predictor_cls
@@ -463,7 +459,7 @@ def retrieve_example_payload(self) -> JumpStartSerializablePayload:
463459 )
464460
465461 def set_deployment_config (
466- self , config_name : str , instance_type : str , accept_draft_model_eula : Optional [ bool ] = False
462+ self , config_name : str , instance_type : str
467463 ) -> None :
468464 """Sets the deployment config to apply to the model.
469465
@@ -483,8 +479,7 @@ def set_deployment_config(
483479 instance_type = instance_type ,
484480 config_name = config_name ,
485481 sagemaker_session = self .sagemaker_session ,
486- role = self .role ,
487- accept_draft_model_eula = accept_draft_model_eula ,
482+ role = self .role
488483 )
489484
490485 @property
@@ -674,6 +669,7 @@ def deploy(
674669 managed_instance_scaling : Optional [str ] = None ,
675670 endpoint_type : EndpointType = EndpointType .MODEL_BASED ,
676671 routing_config : Optional [Dict [str , Any ]] = None ,
672+ model_access_configs : Optional [List [ModelAccessConfig ]] = None ,
677673 ) -> PredictorBase :
678674 """Creates endpoint by calling base ``Model`` class `deploy` method.
679675
@@ -770,6 +766,11 @@ def deploy(
770766 (Default: EndpointType.MODEL_BASED).
771767 routing_config (Optional[Dict]): Settings the control how the endpoint routes
772768 incoming traffic to the instances that the endpoint hosts.
769+ model_access_configs (Optional[List[ModelAccessConfig]]): For models that require Model Access Configs,
770+ provide one or multiple ModelAccessConfig objects to indicate whether model terms of use have been accepted.
771+ The `AcceptEula` value must be explicitly defined as `True` in order to
772+ accept the end-user license agreement (EULA) that some.
773+ (Default: None)
773774
774775 Raises:
775776 MarketplaceModelSubscriptionError: If the caller is not subscribed to the model.
@@ -810,6 +811,7 @@ def deploy(
810811 model_type = self .model_type ,
811812 config_name = self .config_name ,
812813 routing_config = routing_config ,
814+ model_access_configs = model_access_configs ,
813815 )
814816 if (
815817 self .model_type == JumpStartModelType .PROPRIETARY
@@ -819,6 +821,13 @@ def deploy(
819821 f"{ EndpointType .INFERENCE_COMPONENT_BASED } is not supported for Proprietary models."
820822 )
821823
824+ self .additional_model_data_sources = _add_model_access_configs_to_model_data_sources (
825+ self .additional_model_data_sources ,
826+ deploy_kwargs .model_access_configs ,
827+ deploy_kwargs .model_id ,
828+ deploy_kwargs .region ,
829+ )
830+
822831 try :
823832 predictor = super (JumpStartModel , self ).deploy (** deploy_kwargs .to_kwargs_dict ())
824833 except ClientError as e :
@@ -1058,7 +1067,6 @@ def _get_deployment_configs(
10581067 region = self .region ,
10591068 model_version = self .model_version ,
10601069 hub_arn = self .hub_arn ,
1061- accept_draft_model_eula = True ,
10621070 )
10631071 deploy_kwargs = get_deploy_kwargs (
10641072 model_id = self .model_id ,
0 commit comments