Пример #1
0
def collect_AP():
    priorities = Project.calculate_AP()
    Attpoints = pd.DataFrame(list(priorities.items()),columns=['Account','Ap'])
    yesterday = date.today() - timedelta(1)
    Priority_DB = slurm_priority.objects.filter(Date=yesterday)
    # If Priority DB exists merge in the Ap values
    if (Priority_DB.exists()):
        Priority_DATA = pd.DataFrame(
            list(
                Priority_DB.values(
                    'Account',
                    'CPU_hours',
                    'GPU_hours',
                    'P_CPU',
                    'P_GPU',
                    'Qos')))
        SCW = pd.merge(
            Priority_DATA,
            Attpoints,
            on='Account',
            how='left').fillna(0)
        return SCW
    else:
        # Priority DB is empty therfore create default values for projects that
        # are prioritized thease will then be added into the database during
        # the final append step.
        zeros = np.zeros(len(Attpoints['Account']))
        Attpoints['CPU_hours'] = zeros
        Attpoints['GPU_hours'] = zeros
        Attpoints['P_CPU'] = zeros
        Attpoints['P_GPU'] = zeros
        Attpoints['Qos'] = zeros
        return Attpoints