@@ -236,7 +236,12 @@ def _initialize(
236236
237237 # Create sagemaker_client with the botocore_config object
238238 # This config is customized to append SageMaker Python SDK specific user_agent suffix
239- self .sagemaker_client = sagemaker_client or self .boto_session .client ("sagemaker" )
239+ if sagemaker_client is not None :
240+ self .sagemaker_client = sagemaker_client
241+ else :
242+ from sagemaker .core .user_agent import get_user_agent_extra_suffix
243+ config = botocore .config .Config (user_agent_extra = get_user_agent_extra_suffix ())
244+ self .sagemaker_client = self .boto_session .client ("sagemaker" , config = config )
240245
241246 if sagemaker_runtime_client is not None :
242247 self .sagemaker_runtime_client = sagemaker_runtime_client
@@ -1657,111 +1662,6 @@ def update_inference_component(
16571662 self .wait_for_inference_component (inference_component_name )
16581663 return inference_component_name
16591664
1660- def transform (
1661- self ,
1662- job_name ,
1663- model_name ,
1664- strategy ,
1665- max_concurrent_transforms ,
1666- max_payload ,
1667- input_config ,
1668- output_config ,
1669- resource_config ,
1670- experiment_config ,
1671- env : Optional [Dict [str , str ]] = None ,
1672- tags = None ,
1673- data_processing = None ,
1674- model_client_config = None ,
1675- batch_data_capture_config : BatchDataCaptureConfig = None ,
1676- ):
1677- """Create an Amazon SageMaker transform job.
1678-
1679- Args:
1680- job_name (str): Name of the transform job being created.
1681- model_name (str): Name of the SageMaker model being used for the transform job.
1682- strategy (str): The strategy used to decide how to batch records in a single request.
1683- Possible values are 'MultiRecord' and 'SingleRecord'.
1684- max_concurrent_transforms (int): The maximum number of HTTP requests to be made to
1685- each individual transform container at one time.
1686- max_payload (int): Maximum size of the payload in a single HTTP request to the
1687- container in MB.
1688- env (dict): Environment variables to be set for use during the transform job.
1689- input_config (dict): A dictionary describing the input data (and its location) for the
1690- job.
1691- output_config (dict): A dictionary describing the output location for the job.
1692- resource_config (dict): A dictionary describing the resources to complete the job.
1693- experiment_config (dict[str, str]): Experiment management configuration.
1694- Optionally, the dict can contain three keys:
1695- 'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.
1696- The behavior of setting these keys is as follows:
1697- * If `ExperimentName` is supplied but `TrialName` is not a Trial will be
1698- automatically created and the job's Trial Component associated with the Trial.
1699- * If `TrialName` is supplied and the Trial already exists the job's Trial Component
1700- will be associated with the Trial.
1701- * If both `ExperimentName` and `TrialName` are not supplied the trial component
1702- will be unassociated.
1703- * `TrialComponentDisplayName` is used for display in Studio.
1704- tags (Optional[Tags]): List of tags for labeling a transform job.
1705- data_processing(dict): A dictionary describing config for combining the input data and
1706- transformed data. For more, see
1707- https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
1708- model_client_config (dict): A dictionary describing the model configuration for the
1709- job. Dictionary contains two optional keys,
1710- 'InvocationsTimeoutInSeconds', and 'InvocationsMaxRetries'.
1711- batch_data_capture_config (BatchDataCaptureConfig): Configuration object which
1712- specifies the configurations related to the batch data capture for the transform job
1713- """
1714- tags = _append_project_tags (format_tags (tags ))
1715- tags = self ._append_sagemaker_config_tags (
1716- tags , "{}.{}.{}" .format (SAGEMAKER , TRANSFORM_JOB , TAGS )
1717- )
1718- batch_data_capture_config = resolve_class_attribute_from_config (
1719- None ,
1720- batch_data_capture_config ,
1721- "kms_key_id" ,
1722- TRANSFORM_JOB_KMS_KEY_ID_PATH ,
1723- sagemaker_session = self ,
1724- )
1725- output_config = resolve_nested_dict_value_from_config (
1726- output_config , [KMS_KEY_ID ], TRANSFORM_OUTPUT_KMS_KEY_ID_PATH , sagemaker_session = self
1727- )
1728- resource_config = resolve_nested_dict_value_from_config (
1729- resource_config ,
1730- [VOLUME_KMS_KEY_ID ],
1731- TRANSFORM_JOB_VOLUME_KMS_KEY_ID_PATH ,
1732- sagemaker_session = self ,
1733- )
1734- env = resolve_value_from_config (
1735- direct_input = env ,
1736- config_path = TRANSFORM_JOB_ENVIRONMENT_PATH ,
1737- default_value = None ,
1738- sagemaker_session = self ,
1739- )
1740-
1741- transform_request = self ._get_transform_request (
1742- job_name = job_name ,
1743- model_name = model_name ,
1744- strategy = strategy ,
1745- max_concurrent_transforms = max_concurrent_transforms ,
1746- max_payload = max_payload ,
1747- env = env ,
1748- input_config = input_config ,
1749- output_config = output_config ,
1750- resource_config = resource_config ,
1751- experiment_config = experiment_config ,
1752- tags = tags ,
1753- data_processing = data_processing ,
1754- model_client_config = model_client_config ,
1755- batch_data_capture_config = batch_data_capture_config ,
1756- )
1757-
1758- def submit (request ):
1759- logger .info ("Creating transform job with name: %s" , job_name )
1760- logger .debug ("Transform request: %s" , json .dumps (request , indent = 4 ))
1761- self .sagemaker_client .create_transform_job (** request )
1762-
1763- self ._intercept_create_request (transform_request , submit , self .transform .__name__ )
1764-
17651665 def _create_model_request (
17661666 self ,
17671667 name ,
0 commit comments