class_docstr: Artifact uploader
class_docstr_tok: ["Artifact","uploader"]
docstr: Upload an artifact file to S3.
  
  Args:
      file_path (str): the file path of the artifact
      extra_args (dict): Optional extra arguments that may be passed to the upload operation.
          Similar to ExtraArgs parameter in S3 upload_file function. Please refer to the
          ExtraArgs parameter documentation here:
          https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html#the-extraargs-parameter
  
  Returns:
      (str, str): The s3 URI of the uploaded file and the etag of the file.
  
  Raises:
      ValueError: If file does not exist.
docstr_tok: ["Upload","an","artifact","file","to","S3",".","Args",":","file_path","(","str",")",":","the","file","path","of","the","artifact","extra_args","(","dict",")",":","Optional","extra","arguments","that","may","be","passed","to","the","upload","operation",".","Similar","to","ExtraArgs","parameter","in","S3","upload_file","function",".","Please","refer","to","the","ExtraArgs","parameter","documentation","here",":","https",":","\/\/boto3.amazonaws.com\/v1\/documentation\/api\/latest\/guide\/s3-uploading-files.html","#","the-extraargs-parameter","Returns",":","(","str",",","str",")",":","The","s3","URI","of","the","uploaded","file","and","the","etag","of","the","file",".","Raises",":","ValueError",":","If","file","does","not","exist","."]
code: def upload_artifact(self, file_path, extra_args=None):
      """Upload an artifact file to S3.
  
      Args:
          file_path (str): the file path of the artifact
          extra_args (dict): Optional extra arguments that may be passed to the upload operation.
              Similar to ExtraArgs parameter in S3 upload_file function. Please refer to the
              ExtraArgs parameter documentation here:
              https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html#the-extraargs-parameter
  
      Returns:
          (str, str): The s3 URI of the uploaded file and the etag of the file.
  
      Raises:
          ValueError: If file does not exist.
      """
      file_path = os.path.expanduser(file_path)
      if not os.path.isfile(file_path):
          raise ValueError(
              "{} does not exist or is not a file. Please supply a file path.".format(
                  file_path
              )
          )
  
      # If self.artifact_bucket is falsy, it will be set to sagemaker_session.default_bucket.
      # In that case, and if sagemaker_session.default_bucket_prefix exists, self.artifact_prefix
      # needs to be updated too (because not updating self.artifact_prefix would result in
      # different behavior the 1st time this method is called vs the 2nd).
      (
          self.artifact_bucket,
          self.artifact_prefix,
      ) = s3.determine_bucket_and_prefix(
          bucket=self.artifact_bucket,
          key_prefix=self.artifact_prefix,
          sagemaker_session=self.sagemaker_session,
      )
  
      artifact_name = os.path.basename(file_path)
      artifact_s3_key = "{}/{}/{}".format(
          self.artifact_prefix, self.trial_component_name, artifact_name
      )
      self._s3_client.upload_file(
          file_path,
          self.artifact_bucket,
          artifact_s3_key,
          ExtraArgs=extra_args,
      )
      etag = self._try_get_etag(artifact_s3_key)
      return (
          "s3://{}/{}".format(self.artifact_bucket, artifact_s3_key),
          etag,
      )
  
imports: from __future__ import absolute_import
  import json
  import logging
  import os
  import botocore
  from sagemaker import s3
  from sagemaker.experiments._utils import is_already_exist_error
label_desc: Use image node_id 2 for calling the _ArtifactUploader obj's underlying member method code with example usage: obj.upload_artifact(file_path, extra_args) and returns: str,  etag