예제 #1
0
    def get(self, request, test_id=None):
        # first find test set to run
        exp_set = Registry.get(test_id)
        if exp_set is None:
            raise Http404

        runner = Runner()
        runner.add(exp_set)
        result = runner.run()

        # Now let's save all data into database
        run_data = models.Run()
        run_data.save()
        for exp_set_res in result.SetResults.items():
            set_data = models.ExperimentSet.objects.filter(Type=exp_set_res[0])
            if len(set_data) == 0:
                raise Exception("Registered experiment set '" +
                                exp_set_res[0] + "' not found")
            set_data = set_data[0]
            # Save set-vise metrics
            exp_set_res_data = models.ExperimentSetRun(ExperimentSet=set_data,
                                                       Run=run_data)
            exp_set_res_data.save()

            for m in exp_set_res[1].Metrics.items():
                metric_data = models.Metric.objects.filter(
                    ExperimentSet=set_data, Name=m[0])
                if len(metric_data) == 0:
                    raise Exception("Registered metric '" + m[0] +
                                    "' not found")
                metric_data = metric_data[0]
                self._saveMetric(m[1], metric_data, run_data, exp_set_res_data)

            for case_res in exp_set_res[1].ExperimentResults.items():
                # Find appropriate experiment
                exp_data = models.Experiment.objects.filter(
                    ExperimentSet=set_data, Name=case_res[0])

                exp_res_data = models.ExperimentRun(
                    ExperimentSetRun=exp_set_res_data,
                    Experiment=exp_data[0],
                    Run=run_data)
                exp_res_data.save()

                # Save per-experiment metrics
                for m in case_res[1].Metrics.items():
                    metric_data = models.Metric.objects.filter(
                        ExperimentSet=set_data, Name=m[0])
                    if len(metric_data) == 0:
                        raise Exception("Registered metric '" + m[0] +
                                        "' not found")

                    metric_data = metric_data[0]
                    self._saveMetric(m[1], metric_data, run_data,
                                     exp_set_res_data, exp_res_data)

        return redirect(
            reverse('django-pyxperiment:test.view',
                    kwargs={'test_id': test_id}))
예제 #2
0
    def get(self, request, test_id = None) :
        # first find test set to run
        exp_set = Registry.get(test_id)
        if exp_set is None :
            raise Http404

        runner = Runner()
        runner.add(exp_set)
        result = runner.run()

        # Now let's save all data into database
        run_data = models.Run()
        run_data.save()
        for exp_set_res in result.SetResults.items() :
            set_data = models.ExperimentSet.objects.filter(Type=exp_set_res[0])
            if len(set_data) == 0 :
                raise Exception("Registered experiment set '" + exp_set_res[0] + "' not found")
            set_data = set_data[0]
            # Save set-vise metrics
            exp_set_res_data = models.ExperimentSetRun(ExperimentSet = set_data, Run = run_data)
            exp_set_res_data.save()

            for m in exp_set_res[1].Metrics.items() :
                metric_data = models.Metric.objects.filter(ExperimentSet=set_data, Name=m[0])
                if len(metric_data) == 0 :
                    raise Exception("Registered metric '" + m[0] + "' not found")
                metric_data = metric_data[0]
                self._saveMetric(m[1], metric_data, run_data, exp_set_res_data)

            for case_res in exp_set_res[1].ExperimentResults.items() :
                # Find appropriate experiment
                exp_data = models.Experiment.objects.filter(ExperimentSet=set_data, Name=case_res[0])

                exp_res_data = models.ExperimentRun(
                        ExperimentSetRun=exp_set_res_data,
                        Experiment = exp_data[0],
                        Run = run_data)
                exp_res_data.save()

                # Save per-experiment metrics
                for m in case_res[1].Metrics.items() :
                    metric_data = models.Metric.objects.filter(ExperimentSet=set_data, Name=m[0])
                    if len(metric_data) == 0 :
                        raise Exception("Registered metric '" + m[0] + "' not found")

                    metric_data = metric_data[0]
                    self._saveMetric(m[1], metric_data, run_data, exp_set_res_data, exp_res_data)

        return redirect(reverse('django-pyxperiment:test.view', kwargs={'test_id' : test_id}))
예제 #3
0
    def test_Run(self) :

        simple_test = Registry.get('SimpleTest')

        runner = Runner()
        runner.add(simple_test)
        result = runner.run()

        self.assertEquals(len(result.SetResults), 1)

        set_results = result.SetResults['SimpleTest']
        self.assertEquals(len(set_results.ExperimentResults), 3)

        self.assertEquals(set_results.Metrics['TotalSize'].Value, 126)
        self.assertLessEqual(set_results.Metrics['AvgValue'].Value, 1.)
예제 #4
0
    def test_Run(self):

        simple_test = Registry.get('SimpleTest')

        runner = Runner()
        runner.add(simple_test)
        result = runner.run()

        self.assertEquals(len(result.SetResults), 1)

        set_results = result.SetResults['SimpleTest']
        self.assertEquals(len(set_results.ExperimentResults), 3)

        self.assertEquals(set_results.Metrics['TotalSize'].Value, 126)
        self.assertLessEqual(set_results.Metrics['AvgValue'].Value, 1.)