Example #1
0
def reload(request):
    all_experiment_sets = Registry.getInstance()._ExperimentSets.values()

    for mdl_test in models.ExperimentSet.objects.all():
        test_registered = False
        for test in all_experiment_sets:
            if test.Name == mdl_test.Type:
                test_registered = True
                break

        if not test_registered:
            mdl_test.delete()

    for test in all_experiment_sets:
        mdl_test = models.ExperimentSet.objects.filter(Type=test.Name)
        if len(mdl_test) == 0:
            mdl_test = models.ExperimentSet(Type=test.Name)
            mdl_test.save()
        else:
            mdl_test = mdl_test[0]

        reload_cases(test, mdl_test)
        reload_metrics(test, mdl_test)

    return redirect('django-pyxperiment:index')
Example #2
0
    def test_registration(self):
        return
        simple_test = Registry.get('SimpleTest')
        self.assertIsNotNone(simple_test, "Experiment can't be located")

        metrics = list(simple_test.Metrics())
        self.assertEqual(len(metrics), 2)

        cases = list(simple_test.findExperiments())
        self.assertEqual(len(cases), 3)
        simple_test = cases[0]

        metrics = {}
        for m in simple_test.Metrics:
            metrics[m[0]] = m[1]
        self.assertEqual(len(metrics), 4)

        self.assertIn('Is', metrics)
        self.assertEqual(metrics['Is'].Type, Metric.TYPE_BOOLEAN)

        self.assertIn('Message', metrics)
        self.assertEqual(metrics['Message'].Type, Metric.TYPE_STRING)

        self.assertIn('Size', metrics)
        self.assertEqual(metrics['Size'].Type, Metric.TYPE_INTEGER)

        self.assertIn('Value', metrics)
        self.assertEqual(metrics['Value'].Type, Metric.TYPE_FLOAT)
Example #3
0
    def test_registration(self):
        return
        simple_test = Registry.get('SimpleTest')
        self.assertIsNotNone(simple_test, "Experiment can't be located")

        metrics = list(simple_test.Metrics())
        self.assertEqual(len(metrics), 2)

        cases = list(simple_test.findExperiments())
        self.assertEqual(len(cases), 3)
        simple_test = cases[0]

        metrics = {}
        for m in simple_test.Metrics:
            metrics[m[0]] = m[1]
        self.assertEqual(len(metrics), 4)

        self.assertIn('Is', metrics)
        self.assertEqual(metrics['Is'].Type, Metric.TYPE_BOOLEAN)

        self.assertIn('Message', metrics)
        self.assertEqual(metrics['Message'].Type, Metric.TYPE_STRING)

        self.assertIn('Size', metrics)
        self.assertEqual(metrics['Size'].Type, Metric.TYPE_INTEGER)

        self.assertIn('Value', metrics)
        self.assertEqual(metrics['Value'].Type, Metric.TYPE_FLOAT)
Example #4
0
def reload(request):
    all_experiment_sets = Registry.getInstance()._ExperimentSets.values()

    for mdl_test in models.ExperimentSet.objects.all():
        test_registered = False
        for test in all_experiment_sets:
            if test.Name == mdl_test.Type:
                test_registered = True
                break

        if not test_registered:
            mdl_test.delete()

    for test in all_experiment_sets:
        mdl_test = models.ExperimentSet.objects.filter(Type=test.Name)
        if len(mdl_test) == 0:
            mdl_test = models.ExperimentSet(Type=test.Name)
            mdl_test.save()
        else:
            mdl_test = mdl_test[0]

        reload_cases(test, mdl_test)
        reload_metrics(test, mdl_test)

    return redirect('django-pyxperiment:index')
Example #5
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}))
Example #6
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}))
Example #7
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.)
Example #8
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.)
 def test_Run(self):
     simple_test = Registry.get('SimpleTest')
Example #10
0
 def test_Run(self) :
     simple_test = Registry.get('SimpleTest')