예제 #1
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)
예제 #2
0
def lookup_nth_pending_filename(position):
    """Looks up the nth pending file from the sorted list of pending files

    :param int position: position of the pending we will lookup
    :returns str: pending profile at given position
    """
    pending = commands.get_untracked_profiles()
    profiles.sort_profiles(pending)
    if 0 <= position < len(pending):
        return pending[position].realpath
    else:
        raise click.BadParameter(
            "invalid tag '{}' (choose from interval <{}, {}>)".format(
                "{}@p".format(position), '0@p',
                '{}@p'.format(len(pending) - 1)))
예제 #3
0
파일: cli.py 프로젝트: petr-muller/perun
def lookup_nth_pending_filename(position):
    """
    Arguments:
        position(int): position of the pending we will lookup

    Returns:
        str: pending profile at given position
    """
    pending = commands.get_untracked_profiles(
        PCS(store.locate_perun_dir_on(os.getcwd())))
    if 0 <= position < len(pending):
        return pending[position].id
    else:
        raise click.BadParameter(
            "invalid tag '{}' (choose from interval <{}, {}>)".format(
                "{}@p".format(position), '0@p',
                '{}@p'.format(len(pending) - 1)))
예제 #4
0
def test_loading(helpers, pcs_full, valid_profile_pool):
    """Test new feature of loading the profile straight out of profile info

    Expecting correct behaviour
    """
    helpers.populate_repo_with_untracked_profiles(pcs_full.get_path(),
                                                  valid_profile_pool)
    untracked = commands.get_untracked_profiles()
    assert len(untracked) != 0

    first_untracked = untracked[0].load()
    assert isinstance(first_untracked, dict)
    assert 'header' in first_untracked.keys()

    git_repo = git.Repo(pcs_full.get_vcs_path())
    head = str(git_repo.head.commit)

    minor_version_profiles = profiles.load_list_for_minor_version(head)
    assert len(minor_version_profiles) != 0
    first_indexed = minor_version_profiles[0].load()
    assert isinstance(first_indexed, dict)
    assert 'header' in first_indexed.keys()
예제 #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)