<commit_before>import os

import boto3
from django.conf import settings
import logging

logger = logging.getLogger(__name__)


def get_s3_client():
    return boto3.client(
        's3',
        aws_access_key_id=settings.AWS_ACCESS_KEY,
        aws_secret_access_key=settings.AWS_SECRET_KEY,
    )


def upload_to_s3(run_uuid, source_filename, destination_filename, client=None):
    if not client:
        client = get_s3_client()

    asset_path = os.path.join(
        settings.EXPORT_STAGING_ROOT,
        run_uuid,
        source_filename
    )
    asset_remote_path = os.path.join(run_uuid, destination_filename)
    with open(asset_path, 'rb') as asset_file:
        asset_file.seek(0)
        client.put_object(
            Bucket=settings.AWS_BUCKET_NAME,
            Key=asset_remote_path,
            Body=asset_file.read()
        )

    return client.generate_presigned_url(
        'get_object',
        Params={'Bucket': settings.AWS_BUCKET_NAME, 'Key': asset_remote_path}
    ).split('?')[0]<commit_msg>changed boto3 method used to upload_file<commit_after>import os

import boto3
from django.conf import settings
import logging

logger = logging.getLogger(__name__)


def get_s3_client():
    return boto3.client(
        's3',
        aws_access_key_id=settings.AWS_ACCESS_KEY,
        aws_secret_access_key=settings.AWS_SECRET_KEY,
    )


def upload_to_s3(run_uuid, source_filename, destination_filename, client=None):
    if not client:
        client = get_s3_client()

    asset_path = os.path.join(
        settings.EXPORT_STAGING_ROOT,
        run_uuid,
        source_filename
    )
    asset_remote_path = os.path.join(run_uuid, destination_filename)
    # with open(asset_path, 'rb') as asset_file:
    #     asset_file.seek(0)
    client.upload_file(
        asset_path,
        settings.AWS_BUCKET_NAME,
        asset_remote_path
    )

    return client.generate_presigned_url(
        'get_object',
        Params={'Bucket': settings.AWS_BUCKET_NAME, 'Key': asset_remote_path}
    ).split('?')[0]
{'fraction_non_alphanumeric': 0.09068506653523903, 'fraction_numerical': 0.008378511582060127, 'mean_word_length': 3.101010101010101, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5869694', 'n_tokens_mistral': 684, 'n_tokens_neox': 674, 'n_words': 114}