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 a98e4276 authored by Zixian Cai's avatar Zixian Cai
Browse files

Associate taskset with Revision not Project

parent 330efb76
import logging import logging
import click import click
from mubench.models import LocalProject, Revision from mubench.models import LocalRevision
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -10,12 +10,10 @@ logger = logging.getLogger(__name__) ...@@ -10,12 +10,10 @@ logger = logging.getLogger(__name__)
@click.argument('file', type=click.Path(exists=True)) @click.argument('file', type=click.Path(exists=True))
@click.option('--compare', is_flag=True, default=False) @click.option('--compare', is_flag=True, default=False)
def local(file, compare): def local(file, compare):
logger.info("Constructing LocalProject. File: {}".format(file)) logger.info("Constructing a LocalRevision")
p = LocalProject(file=file) revision = LocalRevision(file)
logger.info("Constructing a fake Revision")
revision = Revision(p)
logger.info("Running tasks specified in file") logger.info("Running tasks specified in file")
revision.run_tasks() revision.run_taskset()
logger.info("Generating report, compare?: {}".format(compare)) logger.info("Generating report, compare?: {}".format(compare))
report = revision.generate_report(compare=compare) report = revision.generate_report(compare=compare)
logger.info("Printing report") logger.info("Printing report")
......
from .project import BaseProject, GitLabProject, LocalProject from .project import Project, GitLabProject
from .report import Report from .report import Report
from .result import Result from .result import Result
from .revision import Revision from .revision import Revision, LocalRevision
from .task import Task from .task import Task
from .taskset import TaskSet from .taskset import TaskSet
class BaseProject: class Project:
""" """
A project corresponds to a repository (Git, Mercurial, etc.) A project corresponds to a repository (Git, Mercurial, etc.)
It has a set of tasks (ad-hoc or predefined). It has a set of tasks (ad-hoc or predefined).
...@@ -10,19 +10,7 @@ class BaseProject: ...@@ -10,19 +10,7 @@ class BaseProject:
for k in kwargs: for k in kwargs:
setattr(self, k, kwargs[k]) setattr(self, k, kwargs[k])
def task_set(self):
pass
class GitLabProject(BaseProject): class GitLabProject(Project):
def download_revision(self): def download_revision(self):
pass pass
class LocalProject(BaseProject):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def task_set(self):
from mubench.models import TaskSet
return TaskSet.from_file(self.file)
...@@ -7,14 +7,15 @@ class Revision: ...@@ -7,14 +7,15 @@ class Revision:
It has a hash string, time of creation, and other metadata (branch, etc.). It has a hash string, time of creation, and other metadata (branch, etc.).
""" """
def __init__(self, proj): def __init__(self, **kwargs):
self.proj = proj for k in kwargs:
setattr(self, k, kwargs[k])
def run_tasks(self): def run_taskset(self):
""" """
Run tasks and store the result as attribute Run tasks and store the result as attribute
""" """
ts = self.proj.task_set() ts = self.taskset
ts.run() ts.run()
self.results = {task: task.get_result() for task in ts.tasks} self.results = {task: task.get_result() for task in ts.tasks}
...@@ -38,3 +39,11 @@ class Revision: ...@@ -38,3 +39,11 @@ class Revision:
:return: :return:
""" """
pass pass
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)
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