def plot_queue_length_table(system_name, agreggate_by): indate_table = get_psql_table.get_table('tasks.indate as time', system_name + '.tasks') indate_table = add_queue_column(indate_table, 1) rundate_table = get_psql_table.get_table('runs.rundate as time', system_name + '.runs') rundate_table = add_queue_column(rundate_table, -1) stopdate_table = get_psql_table.get_table( 'runs.stopdate as time, runs.exittype', system_name + '.runs') stopdate_table = add_queue_column(stopdate_table, 0) stopdate_table = alter_exittype(stopdate_table, 1) stopdate_table = drop_exittype_column(stopdate_table) print(stopdate_table) queue_length_table = concatenate_tables(indate_table, rundate_table, stopdate_table) queue_length_table = queue_length_table.sort_values(by=['time']) queue_length_table = queue_length_table.groupby(['time']).sum() queue_length_table = queue_length_table.resample(agreggate_by).sum() # queue_length_table.queue_length = queue_length_table.queue_length.cumsum() queue_length_table.plot() plt.show()
def errors_density(): errors_table = get_psql_table.get_table( 'runs.stopdate as time, runs.exittype', 'mvs10p.runs') errors_table = errors_table.sort_values(by=['time']) errors_table.plot() plt.show()
def get_queue_length_table(): """ Retrieve data from database and transform it to the form convenient for plotting. Function uses Pandas and manipulates the dataframe's structure. """ # Compose a query for database and get a table df = get_psql_table.get_table( 'tasks.indate, runs.rundate', 'mvs100k.tasks join mvs100k.runs on tasks.tid = runs.tid') # Create new dataframe with new ``queue_length`` column with all 1 values. indates = pd.DataFrame() indates["time"] = df.indate indates["queue_length"] = 1 # Create new dataframe with new ``queue_length`` column with all -1 values. rundates = pd.DataFrame() rundates["time"] = df.rundate rundates["queue_length"] = -1 # Concatenate two dataframes queue_length_table = pd.concat([indates, rundates]) queue_length_table = queue_length_table.sort_values(by=['time']) # Exclude repetitive rows queue_length_table = queue_length_table.groupby(['time']).sum() # Summarize all 1 and -1 values and get the total number for every date in the table queue_length_table.queue_length = queue_length_table.queue_length.cumsum() return queue_length_table
def plot_computer_power_pie_chart(tuple): table = get_psql_table.get_table( 'runs.tid,runs.rundate,runs.stopdate,tasks.nproc', 'mvs10p.runs left join' ' mvs10p.tasks on runs.tid = tasks.tid') add_nodes_per_hour_column(table) table = drop_columns(table) table = table.groupby(['tid']).sum() table = table.reset_index() nproc_table = get_psql_table.get_table('tasks.tid,tasks.nproc', 'mvs10p.tasks') table = table.merge(nproc_table, how='left') seaborn.set() fig1, ax1 = plt.subplots() ax1.pie(get_percentage_list(table, tuple)[0], autopct='%1.1f%%', labels=get_percentage_list(table, tuple)[1], shadow=False, startangle=80, pctdistance=0.75, textprops={'fontsize': 14}, wedgeprops=dict(width=0.5)) ax1.set_title('Power distribution', fontsize=16) ax1.axis( 'equal') # Equal aspect ratio ensures that pie is drawn as a circle. plt.show()
def get_error_codes_dict(system): """ Return a dictionary representing number of completion codes in the database. :param system: name of supercomputer system in the database. """ # Compose an sql query to the database and return a dataframe number_of_errors = [ get_psql_table.get_table( 'runs.exittype', '{0}.runs where runs.exittype = {1}'.format( system, i))['exittype'].count() for i in range(-1, 6) ] result_dict = dict(enumerate(number_of_errors, start=-1)) return result_dict