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

from housekeeper.pipelines.mip.build import build_analysis
from housekeeper.pipelines.mip.parse import prepare_inputs, parse_references
from housekeeper.pipelines.mip.core import build_assets, link_asset
from .prepare import prepare_run

log = logging.getLogger(__name__)


def parse(config_data, reference_data, force=False):
    """Parse MIP analysis output."""
    # 1. parse segments of input data
    segments = prepare_inputs(config_data)
    # 2. post-process the output a bit
    prepare_run(segments, force=force)
    # 3. build the records
    new_objs = build_analysis(segments, version='v2.x')
    # 4. parse references
    new_refs = parse_references(reference_data, segments=segments)
    # 5. build assets from references + link to new records
    new_assets = build_assets(new_refs)
    for new_asset, sample in new_assets:
        link_asset(new_objs['run'], new_asset, sample=sample)
    return new_objs
<commit_msg>parse mip version if exists<commit_after># -*- coding: utf-8 -*-
import logging

from housekeeper.pipelines.mip.build import build_analysis
from housekeeper.pipelines.mip.parse import prepare_inputs, parse_references
from housekeeper.pipelines.mip.core import build_assets, link_asset
from .prepare import prepare_run

log = logging.getLogger(__name__)


def parse(config_data, reference_data, force=False):
    """Parse MIP analysis output."""
    # 1. parse segments of input data
    segments = prepare_inputs(config_data)
    # 2. post-process the output a bit
    prepare_run(segments, force=force)
    # 3. build the records
    mip_version = segments['family'].get('MIPVersion', 'v2.x')
    new_objs = build_analysis(segments, version=mip_version)
    # 4. parse references
    new_refs = parse_references(reference_data, segments=segments)
    # 5. build assets from references + link to new records
    new_assets = build_assets(new_refs)
    for new_asset, sample in new_assets:
        link_asset(new_objs['run'], new_asset, sample=sample)
    return new_objs

{'fraction_non_alphanumeric': 0.08980582524271845, 'fraction_numerical': 0.006796116504854369, 'mean_word_length': 4.395287958115183, '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': '7130409', 'n_tokens_mistral': 641, 'n_tokens_neox': 620, 'n_words': 173}