def download_file ( bucket_name , path , target , sagemaker_session ) : path = path . lstrip ( '/' ) boto_session = sagemaker_session . boto_session s3 = boto_session . resource ( 's3' ) bucket = s3 . Bucket ( bucket_name ) bucket . download_file ( path , target )
sagemaker put files to s3 python
Download a Single File from S3 into a local path
def download_file(bucket_name, path, target, sagemaker_session):
    """Download a Single File from S3 into a local path

    Args:
        bucket_name (str): S3 bucket name
        path (str): file path within the bucket
        target (str): destination directory for the downloaded file.
        sagemaker_session (:class:`sagemaker.session.Session`): a sagemaker session to interact with S3.
    """
    path = path.lstrip('/')
    boto_session = sagemaker_session.boto_session

    s3 = boto_session.resource('s3')
    bucket = s3.Bucket(bucket_name)
    bucket.download_file(path, target)