WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 7c36e4aa authored by Zixian Cai's avatar Zixian Cai
Browse files

Use pipelines to process report

parent a98e4276
import logging
import click
from mubench.models import LocalRevision
from mubench.frontend.utils import go_through_pipelines
from mubench.models.revision import LocalRevision
logger = logging.getLogger(__name__)
......@@ -15,6 +16,8 @@ def local(file, compare):
logger.info("Running tasks specified in file")
revision.run_taskset()
logger.info("Generating report, compare?: {}".format(compare))
report = revision.generate_report(compare=compare)
logger.info("Printing report")
report.print()
report = revision.generate_report()
report_pipelines = {
"mubench.models.pipeline.LogOutputPipeline": 42
}
go_through_pipelines(report, report_pipelines)
import logging
logger = logging.getLogger(__name__)
def go_through_pipelines(report, pipelines):
def import_name(name):
import importlib
mod, obj = name.rsplit('.', 1)
return getattr(importlib.import_module(mod), obj)
pipelines_cls = sorted(pipelines.items(), key=lambda x: x[1])
logger.info("Going through pipelines to process the report")
logger.info(pipelines_cls)
pipelines = [import_name(c[0])() for c in pipelines_cls]
for pipeline in pipelines:
report = pipeline.process(report)
import yaml
from mubench.models import Task
from mubench.models.task import Task
def test_rpython_c():
......
from .project import Project, GitLabProject
from .report import Report
from .result import Result
from .revision import Revision, LocalRevision
from .task import Task
from .taskset import TaskSet
import logging
logger = logging.getLogger(__name__)
class Pipeline:
def process(self, report):
pass
class LogOutputPipeline(Pipeline):
def process(self, report):
results = report.results
logger.info("Report for Revision: {}".format(report.revision))
for task in results:
logger.info("Task {}:\n{}".format(task, results[task]))
return report
def get_prev_result(revision, task):
pass
class Report:
"""
Collection of results corresponding to a Revision
"""
def __init__(self, results, revision, compare):
def __init__(self, results, **kwargs):
self.results = results
if compare:
for result in self.results:
result.compare(get_prev_result(revision, result))
def print(self):
for task in self.results:
print(task.name)
print(self.results[task])
for k in kwargs:
setattr(self, k, kwargs[k])
from mubench.models import Report
from mubench.models.report import Report
from mubench.models.taskset import TaskSet
class Revision:
......@@ -26,12 +27,13 @@ class Revision:
"""
pass
def generate_report(self, compare=True):
def generate_report(self):
"""
Generate result from history data points and store it in database
:return:
"""
return Report(self.results, revision=self, compare=compare)
return Report(results=self.results,
revision=self)
def get_report(self):
"""
......@@ -45,5 +47,7 @@ class LocalRevision(Revision):
def __init__(self, file, **kwargs):
super().__init__(**kwargs)
self.file = file
from mubench.models import TaskSet
self.taskset = TaskSet.from_file(self.file)
def __str__(self):
return "LocalRevision({})".format(self.file)
......@@ -4,7 +4,7 @@ import logging
from pathlib import Path
from mubench import SUITE_DIR
from mubench.models import Result
from mubench.models.result import Result
from mubench.lang import get_lang
logger = logging.getLogger(__name__)
......@@ -97,3 +97,6 @@ class Task:
"Result file {} doesn't exist, skipped".format(
self.result_file))
return None
def __str__(self):
return self.name
......@@ -4,7 +4,7 @@ import crayons
from pathlib import Path
from mubench.exceptions import ExecutionFailure
from mubench.models import Task
from mubench.models.task import Task
logger = logging.getLogger(__name__)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment