context info in result

This commit is contained in:
bohanjason 2020-05-29 15:40:17 -04:00 committed by Bohan Zhang
parent 09226edece
commit c8996382dc
2 changed files with 12 additions and 1 deletions

View File

@ -87,6 +87,10 @@ class KnobCatalog(BaseModel):
tunable = models.BooleanField(verbose_name="tunable") tunable = models.BooleanField(verbose_name="tunable")
resource = models.IntegerField(choices=KnobResourceType.choices(), default=4) resource = models.IntegerField(choices=KnobResourceType.choices(), default=4)
@property
def clean_name(self):
return self.name.split('.')[-1]
class MetricCatalog(BaseModel): class MetricCatalog(BaseModel):
dbms = models.ForeignKey(DBMSCatalog) dbms = models.ForeignKey(DBMSCatalog)
@ -97,6 +101,10 @@ class MetricCatalog(BaseModel):
scope = models.CharField(max_length=16) scope = models.CharField(max_length=16)
metric_type = models.IntegerField(choices=MetricType.choices()) metric_type = models.IntegerField(choices=MetricType.choices())
@property
def clean_name(self):
return self.name.split('.')[-1]
class Project(BaseModel): class Project(BaseModel):
user = models.ForeignKey(User) user = models.ForeignKey(User)

View File

@ -565,12 +565,15 @@ def create_and_save_recommendation(recommended_knobs, result, status, **kwargs):
dbms_id = result.dbms.pk dbms_id = result.dbms.pk
formatted_knobs = db.parser.format_dbms_knobs(dbms_id, recommended_knobs) formatted_knobs = db.parser.format_dbms_knobs(dbms_id, recommended_knobs)
config = db.parser.create_knob_configuration(dbms_id, formatted_knobs) config = db.parser.create_knob_configuration(dbms_id, formatted_knobs)
knob_names = recommended_knobs.keys()
knobs = KnobCatalog.objects.filter(name__in=knob_names)
knob_contexts = {knob.clean_name: knob.context for knob in knobs}
retval = dict(**kwargs) retval = dict(**kwargs)
retval.update( retval.update(
status=status, status=status,
result_id=result.pk, result_id=result.pk,
recommendation=config, recommendation=config,
context=knob_contexts
) )
result.next_configuration = JSONUtil.dumps(retval) result.next_configuration = JSONUtil.dumps(retval)
result.save() result.save()