<commit_before>import re
import logging
import math

from .front_end.validate import CPU_REGEX, MEMORY_REGEX

log = logging.getLogger('utils')


def cost_from_msec_mcpu(app, msec_mcpu):
    # https://cloud.google.com/compute/all-pricing
    # persistent SSD: $0.17 GB/month
    # average number of days per month = 365.25 / 12 = 30.4375

    avg_n_days_per_month = 30.4375

    if app['worker_type'] == 'standard':
        cpu_cost_per_core_hour = 0.01
    elif app['worker_type'] == 'highcpu':
        cpu_cost_per_core_hour = 0.0075
    else:
        assert app['worker_type'] == 'highmem'
        cpu_cost_per_core_hour = 0.0125

    disk_cost_per_core_hour = 0.17 * app['worker_disk_size_gb'] / avg_n_days_per_month / 24 / app['worker_cores']
    cost_per_core_sec = (cpu_cost_per_core_hour + disk_cost_per_core_hour) / 3600

    return msec_mcpu * cost_per_core_sec * 0.001 * 0.001


def parse_cpu_in_mcpu(cpu_string):
    match = CPU_REGEX.fullmatch(cpu_string)
    if match:
        number = float(match.group(1))
        if match.group(2) == 'm':
            number /= 1000
        return int(number * 1000)
    return None


conv_factor = {
    'K': 1000, 'Ki': 1024,<commit_msg>[batch] update cost calculation (#8024)<commit_after>import re
import logging
import math

from .front_end.validate import CPU_REGEX, MEMORY_REGEX

log = logging.getLogger('utils')


def cost_from_msec_mcpu(app, msec_mcpu):
    worker_cores = app['worker_cores']

    # https://cloud.google.com/compute/all-pricing

    # per instance costs
    # persistent SSD: $0.17 GB/month
    # average number of days per month = 365.25 / 12 = 30.4375
    avg_n_days_per_month = 30.4375

    disk_cost_per_instance_hour = 0.17 * app['worker_disk_size_gb'] / avg_n_days_per_month / 24

    ip_cost_per_instance_hour = 0.004

    instance_cost_per_instance_hour = disk_cost_per_instance_hour + ip_cost_per_instance_hour

    # per core costs
    if app['worker_type'] == 'standard':
        cpu_cost_per_core_hour = 0.01
    elif app['worker_type'] == 'highcpu':
        cpu_cost_per_core_hour = 0.0075
    else:
        assert app['worker_type'] == 'highmem'
        cpu_cost_per_core_hour = 0.0125

    service_cost_per_core_hour = 0.01

    total_cost_per_core_hour = (
        cpu_cost_per_core_hour +
        instance_cost_per_instance_hour / worker_cores +
        service_cost_per_core_hour)

    return (msec_mcpu * 0.001 * 0.001) * (total_cost_per_core_hour / 3600)


def parse_cpu_in_mcpu(cpu_string):
    match = CPU_REGEX.fullmatch(cpu_string)
    if match:
        number = float(match.group(1))
        if match.group(2) == 'm':
            number /= 1000
        return int(number * 1000)
    return None


conv_factor = {
    'K': 1000, 'Ki': 1024,
{'fraction_non_alphanumeric': 0.10332238043081417, 'fraction_numerical': 0.055129609346476816, 'mean_word_length': 3.208909370199693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6677154', 'n_tokens_mistral': 1119, 'n_tokens_neox': 969, 'n_words': 191}