class_docstr: SageMaker ``MultiDataModel`` can be used to deploy multiple models to the same ``Endpoint``.
  
  And also deploy additional models to an existing SageMaker multi-model ``Endpoint``
class_docstr_tok: ["SageMaker","``","MultiDataModel","``","can","be","used","to","deploy","multiple","models","to","the","same","``","Endpoint","``",".","And","also","deploy","additional","models","to","an","existing","SageMaker","multi-model","``","Endpoint","``"]
docstr: Adds a model to the ``MultiDataModel``.
  
  It is done by uploading or copying the model_data_source artifact to the given
  S3 path model_data_path relative to model_data_prefix
  
  Args:
      model_source: Valid local file path or S3 path of the trained model artifact
      model_data_path: S3 path where the trained model artifact
          should be uploaded relative to ``self.model_data_prefix`` path. (default: None).
          If None, then the model artifact is uploaded to a path relative to model_data_prefix
  
  Returns:
      str: S3 uri to uploaded model artifact
docstr_tok: ["Adds","a","model","to","the","``","MultiDataModel","``",".","It","is","done","by","uploading","or","copying","the","model_data_source","artifact","to","the","given","S3","path","model_data_path","relative","to","model_data_prefix","Args",":","model_source",":","Valid","local","file","path","or","S3","path","of","the","trained","model","artifact","model_data_path",":","S3","path","where","the","trained","model","artifact","should","be","uploaded","relative","to","``","self.model_data_prefix","``","path",".","(","default",":","None",")",".","If","None",",","then","the","model","artifact","is","uploaded","to","a","path","relative","to","model_data_prefix","Returns",":","str",":","S3","uri","to","uploaded","model","artifact"]
code: def add_model(self, model_data_source, model_data_path=None):
      """Adds a model to the ``MultiDataModel``.
  
      It is done by uploading or copying the model_data_source artifact to the given
      S3 path model_data_path relative to model_data_prefix
  
      Args:
          model_source: Valid local file path or S3 path of the trained model artifact
          model_data_path: S3 path where the trained model artifact
              should be uploaded relative to ``self.model_data_prefix`` path. (default: None).
              If None, then the model artifact is uploaded to a path relative to model_data_prefix
  
      Returns:
          str: S3 uri to uploaded model artifact
      """
      parse_result = urlparse(model_data_source)
  
      # If the model source is an S3 path, copy the model artifact to the destination S3 path
      if parse_result.scheme == "s3":
          source_bucket, source_model_data_path = s3.parse_s3_url(
              model_data_source
          )
          copy_source = {
              "Bucket": source_bucket,
              "Key": source_model_data_path,
          }
  
          if not model_data_path:
              model_data_path = source_model_data_path
  
          # Construct the destination path
          dst_url = s3.s3_path_join(
              self.model_data_prefix, model_data_path
          )
          (
              destination_bucket,
              destination_model_data_path,
          ) = s3.parse_s3_url(dst_url)
  
          # Copy the model artifact
          self.s3_client.copy(
              copy_source,
              destination_bucket,
              destination_model_data_path,
          )
          return s3.s3_path_join(
              "s3://", destination_bucket, destination_model_data_path
          )
  
      # If the model source is a local path, upload the local model artifact to the destination
      # S3 path
      if os.path.exists(model_data_source):
          destination_bucket, dst_prefix = s3.parse_s3_url(
              self.model_data_prefix
          )
          if model_data_path:
              dst_s3_uri = s3.s3_path_join(dst_prefix, model_data_path)
          else:
              dst_s3_uri = s3.s3_path_join(
                  dst_prefix, os.path.basename(model_data_source)
              )
          self.s3_client.upload_file(
              model_data_source, destination_bucket, dst_s3_uri
          )
          # return upload_path
          return s3.s3_path_join(
              "s3://", destination_bucket, dst_s3_uri
          )
  
      # Raise error if the model source is of an unexpected type
      raise ValueError(
          "model_source must either be a valid local file path or s3 uri. Received: "
          '"{}"'.format(model_data_source)
      )
  
file_path: sagemaker-python-sdk/src/sagemaker/multidatamodel.py
imports: from __future__ import absolute_import
  import os
  from typing import Union, Optional
  from six.moves.urllib.parse import urlparse
  import sagemaker
  from sagemaker import local, s3
  from sagemaker.deprecations import removed_kwargs
  from sagemaker.model import Model
  from sagemaker.session import Session
  from sagemaker.utils import pop_out_unused_kwarg, format_tags
  from sagemaker.workflow.entities import PipelineVariable
label_desc: Use image node_id 4 for calling the MultiDataModel obj's underlying member method code with example usage: obj.add_model(model_data_source, model_data_path) and returns: s3, s3