Exemple #1
0
def get_profiles_numbers(pcs, repo_path, vcs_type):
    """Function for loading two profiles which are to be compared
    :param PCS pcs: object with performance control system wrapper
    :param str repo_path: path to repository
    :param str vcs_type: type of underlying vcs
    :return: njson containing numbers of profile types and degradation info, 404 NOT FOUND otherwise
    """
    original_path = os.getcwd()
    os.chdir(repo_path)

    try:
        branches = vcs.walk_major_versions(vcs_type, repo_path)
        branches_output = []

        for branch in branches:
            profiles = commands.get_minor_version_profiles(pcs, branch.head);
            profile_numbers = commands.calculate_profile_numbers_per_type(profiles)

            numbers = {
                'time': 0,
                'memory': 0,
                'mixed': 0,
                'all': 0,
            }

            for key,number in profile_numbers.items():
                numbers[str(key)] = number

            degs = check.count_degradations_per_group(check.load_degradation_list_for(pcs.get_object_directory(), branch.head))
            degs = formatter.format_degradation_numbers(degs)

            branches_output.append({ 'branch' : branch.name, 'commit': branch.head, 'profiles': numbers, 'performance': degs})

        profiles_new, formatted, jsn = get_all_repo_profiles(vcs_type, repo_path)
        profile_numbers = commands.calculate_profile_numbers_per_type(profiles_new)

        numbers = {
            'time': 0,
            'memory': 0,
            'mixed': 0,
            'all': 0,
        }

        for key,number in profile_numbers.items():
            numbers[str(key)] = number

        os.chdir(original_path)
        return json.dumps({'all': numbers, 'branches': branches_output})

    except Exception as e:
        os.chdir(original_path)
        eprint(e)
        return create_response(e, 404)
Exemple #2
0
def get_single_profile_info(pcs, minor_version, profile_source):
    """Function for loading single performance profile info
    :param PCS pcs: object with performance control system wrapper
    :param str minor_version: commit to which the profiles belongs
    :param str profile_source: name of the performance profile
    :return: dictionary containing performance profile info
    """

    try:
        profiles_objs = commands.get_minor_version_profiles(pcs, minor_version);
        for num, profile_obj in enumerate(profiles_objs):
            if (profile_obj.source == profile_source):
                perf_profile = profile.load_profile_from_file(profile_obj.realpath, is_raw_profile=False)
                options = [o for o in query.all_resource_fields_of(perf_profile)]
                numerical = [o for o in query.all_numerical_resource_fields_of(perf_profile)]
                dataframe = convert.resources_to_pandas_dataframe(perf_profile)

                for option in options:
                    dataframe = dataframe[pandas.notnull(dataframe[option])]
                
                dataframe = dataframe.astype(str)
                resource_values = dataframe.to_dict(orient='records')

                formatted = formatter.format_single_profile_info(profile_obj, minor_version, options, numerical, resource_values)

                return formatted, json.dumps({'profile' : formatted})

        profiles_objs = commands.get_untracked_profiles(pcs);
        for num, profile_obj in enumerate(profiles_objs):
            if (profile_obj.source == profile_source):
                perf_profile = profile.load_profile_from_file(profile_obj.realpath, is_raw_profile=True)
                options = [o for o in query.all_resource_fields_of(perf_profile)]
                numerical = [o for o in query.all_numerical_resource_fields_of(perf_profile)]
                dataframe = convert.resources_to_pandas_dataframe(perf_profile)
                
                for option in options:
                    dataframe = dataframe[pandas.notnull(dataframe[option])]

                dataframe = dataframe.astype(str)
                resource_values = dataframe.to_dict(orient='records')

                formatted = formatter.format_single_profile_info(profile_obj, minor_version, options, numerical, resource_values)
                
                return formatted, json.dumps({'profile' : formatted})

        return create_response('Something went wrong', 404)

    except Exception as e:
        eprint(e)
        return create_response(e, 404)
Exemple #3
0
def get_repo_branch_commits(pcs, vcs_type, repo_path, branch_name):
    """Function for loading information about all commits of a branch
    :param PCS pcs: object with performance control system wrapper
    :param str vcs_type: type of the version control system
    :param str repo_path: path to the repository
    :param str branch_name: name of the branch
    :return: list of minor versions info
    """
    output = []

    try:
        minor_versions = helper_get_repo_branch_commits(vcs_type, repo_path, branch_name)

        branches = vcs.walk_major_versions(vcs_type, repo_path)
        for branch in branches:
            if (branch.name == branch_name):
                branch_head = branch.head

        for minor_version in minor_versions:
            head = 'head' if (minor_version.checksum == branch_head) else ''

            degs = check.count_degradations_per_group(check.load_degradation_list_for(pcs.get_object_directory(), minor_version.checksum))
            degs = formatter.format_degradation_numbers(degs)

            profiles = commands.get_minor_version_profiles(pcs, minor_version.checksum);
            profile_numbers = commands.calculate_profile_numbers_per_type(profiles)
            
            numbers = {
                'time': 0,
                'memory': 0,
                'mixed': 0,
                'all': 0,
            }

            for key,number in profile_numbers.items():
                numbers[str(key)] = number

            output.append(formatter.format_minor_versions_of_branch(minor_version, branch_name, head, numbers, degs))

        return output, json.dumps({'commits' : output})

    except Exception as e:
        eprint(e)
        return '', create_response(e, 404)
Exemple #4
0
def register_profile_of_minor_version(pcs, minor_version, profile_path, profile_id):
    """Function for registering performance profile of a minor version
    :param PCS pcs: object with performance control system wrapper
    :param str minor_version_sha: minor version SHA
    :param str profile_path: path to the performance profile
    :param str profile_id: name of the performance profile
    :return: new profile path on success, otherwise 404 NOT FOUND
    """
    try: 
        commands.add([profile_path], minor_version, keep_profile=False)
        profiles = commands.get_minor_version_profiles(pcs, minor_version);
        for perf_profile in profiles:
            if (perf_profile.source == profile_id):
                return jsonify({'path' : perf_profile.realpath})

        return create_response('No such performance profile', 404)
    
    except Exception as e:
        eprint(e)
        return create_response(e, 404)
Exemple #5
0
def get_single_minor_version_profiles(pcs, minor_version, branch_name, repo_path):
    """Function for loading performance profiles of a single minor version
    :param PCS pcs: object with performance control system wrapper
    :param str minor_version: minor version SHA
    :return: list of performance profiles
    """
    output = []
    output_objs = []

    try:
        # registered profiles
        profiles_objs = commands.get_minor_version_profiles(pcs, minor_version);
        
        if (not profiles_objs):
            os.chdir(repo_path)

        for num, profile_obj in enumerate(profiles_objs):
            output.append(formatter.format_profiles(profile_obj, minor_version, True, 'remove', branch_name))
            output_objs.append(profile_obj)

        # pending profiles
        profiles_objs = commands.get_untracked_profiles(pcs);

        if (not profiles_objs):
            os.chdir(repo_path)

        for num, profile_obj in enumerate(profiles_objs):
            unpacked_profile = profile.load_profile_from_file(profile_obj.realpath, is_raw_profile=True)
            if (unpacked_profile['origin'] == minor_version):
                output.append(formatter.format_profiles(profile_obj, minor_version, False, 'register', branch_name))
                output_objs.append(profile_obj)
        
        return output_objs, output, json.dumps({'profiles' : output})

    except Exception as e:
        eprint(e)
        return '', '', create_response(e, 404)