<commit_before># -*- coding:utf-8 -*-

import os
import json
from decimal import Decimal

import boto3


def main(report, config, output_summary):

    # dynamo
    dynamodb = boto3.resource('dynamodb',
                              aws_access_key_id=config['aws_access_key_id'],
                              aws_secret_access_key=config['aws_secret_access_key'],
                              region_name=config['region'])
    table = dynamodb.Table(config['table'])
    item = {
        "hashkey": report.key,
        "title": report.title,
        "one_host": report.summary.one.host,
        "other_host": report.summary.other.host,
        "same_count": Decimal(report.summary.status.same),
        "different_count": Decimal(report.summary.status.different) + Decimal(report.summary.status.same_without_order),
        "failure_count": Decimal(report.summary.status.failure),
        "start": report.summary.time.start,
        "end": report.summary.time.end
    }
    table.put_item(Item=item)

    # "report": json.loads(report.to_json(), parse_float=Decimal)

    # s3
    s3 = boto3.client('s3',
                      aws_access_key_id=config['aws_access_key_id'],
                      aws_secret_access_key=config['aws_secret_access_key'],
                      region_name=config['region'])

    def upload_responses(which: str):
        dir = f'{output_summary.response_dir}/{report.key}'
        for file in os.listdir(f'{dir}/{which}'):
            s3.upload_file(Bucket=config['bucket'],
                           Key=f'{report.key}/{which}/{file}',
                           Filename=f'{dir}/{which}/{file}')

    # report
    s3.put_object(Bucket=config['bucket'],
                  Key=f'{report.key}/report.json',
                  Body=report.to_json())

    # details
    upload_responses("one")
    upload_responses("other")

    return report<commit_msg>:hammer: Remove AC from config<commit_after># -*- coding:utf-8 -*-

import os
from decimal import Decimal
from owlmixin import OwlMixin
from modules.models import Report, OutputSummary
import boto3


class Config(OwlMixin):
    def __init__(self, table, bucket):
        self.table: str = table
        self.bucket: str = bucket


def main(report: Report, config_dict: dict, output_summary: OutputSummary):
    config: Config = Config.from_dict(config_dict or {})

    # dynamo
    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table(config.table)
    item = {
        "hashkey": report.key,
        "title": report.title,
        "one_host": report.summary.one.host,
        "other_host": report.summary.other.host,
        "same_count": Decimal(report.summary.status.same),
        "different_count": Decimal(report.summary.status.different) + Decimal(report.summary.status.same_without_order),
        "failure_count": Decimal(report.summary.status.failure),
        "start": report.summary.time.start,
        "end": report.summary.time.end
    }
    table.put_item(Item=item)

    # s3
    s3 = boto3.client('s3')

    def upload_responses(which: str):
        dir = f'{output_summary.response_dir}/{report.key}'
        for file in os.listdir(f'{dir}/{which}'):
            s3.upload_file(Bucket=config.bucket,
                           Key=f'{report.key}/{which}/{file}',
                           Filename=f'{dir}/{which}/{file}')

    # report
    s3.put_object(Bucket=config.bucket,
                  Key=f'{report.key}/report.json',
                  Body=report.to_json())

    # details
    upload_responses("one")
    upload_responses("other")

    return report
{'fraction_non_alphanumeric': 0.13406101315421215, 'fraction_numerical': 0.005037783375314861, 'mean_word_length': 2.503921568627451, 'pattern_counts': {'":': 19, '<': 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': '1994845', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1089, 'n_words': 170}