<commit_before>import boto3
import json
import sys

def get_runtime_info(bucket, key):
    """
    Download runtime information from S3 at deserialize
    """
    s3 = boto3.resource('s3')

    runtime_meta_key = key.replace(".tar.gz", ".meta.json")
    
    json_str = s3.meta.client.get_object(Bucket=bucket, Key=runtime_meta_key)['Body'].read()
    runtime_meta = json.loads(json_str)

    return runtime_meta

def version_str(version_info):
    return "{}.{}".format(version_info[0], version_info[1])

def runtime_key_valid(bucket, key):
    runtime_meta = get_runtime_info(bucket, key)
    return runtime_valid(runtime_meta)

def runtime_valid(runtime_meta):
    """
    Basic checks
    """
    # FIXME at some point we should attempt to match modules
    # more closely 
    this_version_str = version_str(sys.version_info)

    return this_version_str == runtime_meta['python_ver']

<commit_msg>python 3 decode bytes to str<commit_after>import boto3
import json
import sys

def get_runtime_info(bucket, key):
    """
    Download runtime information from S3 at deserialize
    """
    s3 = boto3.resource('s3')

    runtime_meta_key = key.replace(".tar.gz", ".meta.json")
    
    json_str = s3.meta.client.get_object(Bucket=bucket, Key=runtime_meta_key)['Body'].read()
    runtime_meta = json.loads(json_str.decode("ascii"))

    return runtime_meta

def version_str(version_info):
    return "{}.{}".format(version_info[0], version_info[1])

def runtime_key_valid(bucket, key):
    runtime_meta = get_runtime_info(bucket, key)
    return runtime_valid(runtime_meta)

def runtime_valid(runtime_meta):
    """
    Basic checks
    """
    # FIXME at some point we should attempt to match modules
    # more closely 
    this_version_str = version_str(sys.version_info)

    return this_version_str == runtime_meta['python_ver']


{'fraction_non_alphanumeric': 0.11268372346216658, 'fraction_numerical': 0.009254218835057159, 'mean_word_length': 4.148459383753502, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6841230', 'n_tokens_mistral': 594, 'n_tokens_neox': 586, 'n_words': 129}