Exemplo n.º 1
0
    def calculate_per_workload_wstats_per_stage(
            self, workloads: Iterable[str], stage_index: int,
            filter_nodes: List[str]) -> Dict[str, WStat]:
        """
        Calculate WStat for all workloads in list for stage (stage_index).
        Takes data from all nodes.
        """
        workloads_wstats: Dict[str, WStat] = {}
        for workload in workloads:
            # filter tasks of a given workload
            tasks = [
                task for task in self.stages[stage_index].tasks.values()
                if task.workload_name == workload
            ]
            # filter out tasks which were run on >>filter_nodes<<
            tasks = [task for task in tasks if task.node not in filter_nodes]

            # avg but from 12 sec for a single task
            throughputs_list = [
                task.get_throughput('avg') for task in tasks
                if task.get_throughput('avg') is not None
            ]
            latencies_list = [
                task.get_latency('avg') for task in tasks
                if task.get_latency('avg') is not None
            ]

            if len(throughputs_list) == 0:
                exception_value = float('inf')
                t_max, t_min, t_avg, t_stdev = [exception_value] * 4
                l_max, l_min, l_avg, l_stdev = [exception_value] * 4
            elif len(throughputs_list) == 1:
                t_max, t_min, t_avg, t_stdev = [
                    throughputs_list[0], throughputs_list[0],
                    throughputs_list[0], 0
                ]
                l_max, l_min, l_avg, l_stdev = [
                    throughputs_list[0], throughputs_list[0],
                    throughputs_list[0], 0
                ]
            else:
                t_max, t_min, t_avg, t_stdev = max(throughputs_list), min(throughputs_list), \
                                               statistics.mean(throughputs_list), statistics.stdev(
                    throughputs_list)
                l_max, l_min, l_avg, l_stdev = \
                    max(latencies_list), min(latencies_list),\
                    statistics.mean(latencies_list), statistics.stdev(latencies_list)

            workloads_wstats[workload] = WStat(
                latency=Stat(l_avg, l_min, l_max, l_stdev),
                throughput=Stat(t_avg, t_min, t_max, t_stdev),
                count=len(tasks),
                name=workload)
        return workloads_wstats
Exemplo n.º 2
0
    def show_stats_answers(self,**data):
         self.g_user = cherrypy.session.get('g_user')
         roles = ['admin', 'ta', 'final']
         self.page_for(roles)
         header = 'Statistics Graph:'
         ipath = Markup('TA/Admin: <a href="../statistics">Assignment Statistics</a> > <b>Statistics by Answers</b>')
         self.s_data = {}
         s_data = {}
         
         sql = """
             SELECT a.q_no q_no, s.score score, q.name question,
                    count(distinct a.student_id) number
             FROM Score_and_comment s, Answers a, Assignment asg,
                  Questions q, Associated_with aw 
             WHERE  asg.name=%s
               and asg.s_no=aw.s_no
               and aw.q_no=a.q_no
               and q.q_no = a.q_no
               and a.a_no=s.a_no 
          group by s.score, a.q_no
          order by s.score, a.q_no
                """
         db = mysql.DB()
         results = db.do_query(sql, (data['assignment'],))

         for row in results:
             tmp_row = {'s_no':row['q_no'],
                        'finalGrade':row['score'], 'number':row['number']}  
              
             stat = Stat(**tmp_row)
             stat.set_year('')
             stat.question = row['question']

             s_data[stat.s_no, stat.finalGrade, stat.Year]= stat
         self.s_data = s_data

         def compareStat(s1,s2):
            if s1.question != s2.question:
                return cmp(s1.question, s2.question)
            if s1.finalGrade != s2.finalGrade:
                return cmp(s1.finalGrade, s2.finalGrade)
            return 0
         stats = sorted(self.s_data.values(),cmp=compareStat)

         return template.render(ipath = ipath, header=header, stats=stats)
Exemplo n.º 3
0
    def show_stats(self,**data):
        self.g_user = cherrypy.session.get('g_user')
        roles = ['admin', 'ta', 'final']
        self.page_for(roles)
        header = 'Statistical Graph'
        ipath = Markup('Admin/TA <a href="../statistics">Assignment Statistics</a> > <b>Statistics by Assignment</b>')
        self.s_data = {}
        errors = {}
        s_data = {}
     
        if (self.g_term == ""):
            self.g_term = cherrypy.session.get('g_term')
        
        s = ""
        if data['split2'] == 'year':
           s = ", s.year"

        st = " order by g.finalGrade"   
        
        if data['assignment_all'] == 'all':
           sql = "Select g.s_no s_no, g.finalGrade finalGrade, count(distinct g.student_id) number, s.year Year, \
                  5*count(distinct g.student_id) ncount FROM Student s, Grade g  where \
                  g.student_id=s.user_id group by g.finalGrade"
        else:       
           sql = "SELECT g.s_no s_no, g.finalGrade finalGrade,\
                  count(distinct g.student_id) number, s.year Year, \
                  5*count(distinct g.student_id) ncount FROM Grade g, \
                  Student s, Assignment a WHERE g.student_id=s.user_id and \
                  g.s_no=a.s_no and a.name='%s' group by g.s_no, \
                  g.finalGrade" % (data['assignment_all'])
            

        sql = sql + s + st     
    
        db = mysql.DB()
        results = db.do_query(sql)
        for row in results:
            tmp_row = {'s_no':row['s_no'], 'finalGrade':row['finalGrade'], 'number':row['number']}
            stat = Stat(**tmp_row)
            
            if data['split2'] == 'year':
               stat.set_year(row['Year'])
            else:
               stat.set_year('')
            stat.set_ncount(row['ncount'])
            s_data[stat.s_no, stat.finalGrade, stat.Year]= stat
            db.close()
        self.s_data = s_data
	    
        stats = self.s_data.values()
        
        
        return template.render(ipath=ipath, header=header, stats=stats)
Exemplo n.º 4
0
    def transform(self, json: dict):
        # variables
        countries = json.keys()
        all_data = []

        # loop
        for country in countries:

            # build array of json
            for i, stat in enumerate(json[country]):

                date = datetime.strptime(stat["date"], "%Y-%m-%d").date()
                data = Stat(
                    id=f"{country}{date}",
                    country=country,
                    date=date,
                    confirmed=stat["confirmed"],
                    deaths=stat["deaths"],
                    recovered=stat["recovered"],
                )
                all_data.append(data)

        # return
        return all_data