Made the workload editable so it can be edited in the admin view and cleaned up the admin view and template
This commit is contained in:
parent
94fd374ec7
commit
423140169f
|
@ -13,7 +13,7 @@ profile=no
|
||||||
|
|
||||||
# Add files or directories to the blacklist. They should be base names, not
|
# Add files or directories to the blacklist. They should be base names, not
|
||||||
# paths.
|
# paths.
|
||||||
ignore=CVS,.git,manage.py,0001_initial.py,0002_enable_compression.py,0003_load_initial_data.py,0004_add_lhs.py,0005_add_workload_field.py,0006_session_hyperparameters.py,0007_executiontime.py,0008_change_result_taskids_field.py,0009_change_executiontime_function_field.py,0010_add_pipeline_data_field.py,0011_knob_bound_fields.py,credentials.py,create_knob_settings.py
|
ignore=CVS,.git,manage.py,0001_initial.py,0002_enable_compression.py,0003_load_initial_data.py,0004_add_lhs.py,0005_add_workload_field.py,0006_session_hyperparameters.py,0007_executiontime.py,0008_change_result_taskids_field.py,0009_change_executiontime_function_field.py,0010_add_pipeline_data_field.py,0011_knob_bound_fields.py,0012_make_workload_status_editable.py,credentials.py,create_knob_settings.py
|
||||||
|
|
||||||
# ignore-patterns=**/migrations/*.py
|
# ignore-patterns=**/migrations/*.py
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from .models import (BackupData, DBMSCatalog, ExecutionTime,
|
||||||
MetricData, PipelineData, PipelineRun,
|
MetricData, PipelineData, PipelineRun,
|
||||||
Project, Result, Session, Workload, Hardware,
|
Project, Result, Session, Workload, Hardware,
|
||||||
SessionKnob)
|
SessionKnob)
|
||||||
from .types import VarType
|
from .types import VarType, WorkloadStatusType
|
||||||
|
|
||||||
|
|
||||||
class DBMSCatalogAdmin(admin.ModelAdmin):
|
class DBMSCatalogAdmin(admin.ModelAdmin):
|
||||||
|
@ -122,9 +122,20 @@ class PipelineRunAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
|
|
||||||
class WorkloadAdmin(admin.ModelAdmin):
|
class WorkloadAdmin(admin.ModelAdmin):
|
||||||
list_display = ('name', 'dbms', 'hardware')
|
list_display = ('name', 'dbms', 'project', 'workload_status')
|
||||||
list_filter = (('dbms', admin.RelatedOnlyFieldListFilter),
|
list_filter = (('dbms', admin.RelatedOnlyFieldListFilter),
|
||||||
('hardware', admin.RelatedOnlyFieldListFilter))
|
('project', admin.RelatedOnlyFieldListFilter))
|
||||||
|
|
||||||
|
def workload_status(self, instance): # pylint: disable=no-self-use
|
||||||
|
if instance.status == WorkloadStatusType.MODIFIED:
|
||||||
|
color = 'red'
|
||||||
|
elif instance.status == WorkloadStatusType.PROCESSING:
|
||||||
|
color = 'orange'
|
||||||
|
else: # instance.status == WorkloadStatusType.PROCESSED
|
||||||
|
color = 'green'
|
||||||
|
return format_html('<span style="color: {};">{}</span>'.format(
|
||||||
|
color, WorkloadStatusType.name(instance.status)))
|
||||||
|
workload_status.short_description = 'Status'
|
||||||
|
|
||||||
|
|
||||||
class TaskMetaAdmin(admin.ModelAdmin):
|
class TaskMetaAdmin(admin.ModelAdmin):
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.27 on 2020-04-02 18:37
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('website', '0011_knob_bound_fields'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='workload',
|
||||||
|
name='status',
|
||||||
|
field=models.IntegerField(choices=[(1, 'MODIFIED'), (2, 'PROCESSING'), (3, 'PROCESSED')], default=1),
|
||||||
|
),
|
||||||
|
]
|
|
@ -394,8 +394,6 @@ class WorkloadManager(models.Manager):
|
||||||
|
|
||||||
class Workload(BaseModel):
|
class Workload(BaseModel):
|
||||||
|
|
||||||
# __DEFAULT_FMT = '{db}_{hw}_UNASSIGNED'.format
|
|
||||||
|
|
||||||
objects = WorkloadManager()
|
objects = WorkloadManager()
|
||||||
|
|
||||||
dbms = models.ForeignKey(DBMSCatalog)
|
dbms = models.ForeignKey(DBMSCatalog)
|
||||||
|
@ -403,8 +401,7 @@ class Workload(BaseModel):
|
||||||
name = models.CharField(max_length=128, verbose_name='workload name')
|
name = models.CharField(max_length=128, verbose_name='workload name')
|
||||||
project = models.ForeignKey(Project)
|
project = models.ForeignKey(Project)
|
||||||
status = models.IntegerField(choices=WorkloadStatusType.choices(),
|
status = models.IntegerField(choices=WorkloadStatusType.choices(),
|
||||||
default=WorkloadStatusType.MODIFIED,
|
default=WorkloadStatusType.MODIFIED)
|
||||||
editable=False)
|
|
||||||
|
|
||||||
def delete(self, using=DEFAULT_DB_ALIAS, keep_parents=False):
|
def delete(self, using=DEFAULT_DB_ALIAS, keep_parents=False):
|
||||||
# The results should not have corresponding workloads.
|
# The results should not have corresponding workloads.
|
||||||
|
@ -421,20 +418,6 @@ class Workload(BaseModel):
|
||||||
class Meta: # pylint: disable=no-init
|
class Meta: # pylint: disable=no-init
|
||||||
unique_together = ("dbms", "hardware", "name", "project")
|
unique_together = ("dbms", "hardware", "name", "project")
|
||||||
|
|
||||||
# @property
|
|
||||||
# def isdefault(self):
|
|
||||||
# return self.cluster_name == self.default
|
|
||||||
#
|
|
||||||
# @property
|
|
||||||
# def default(self):
|
|
||||||
# return self.__DEFAULT_FMT(db=self.dbms.pk,
|
|
||||||
# hw=self.hardware.pk)
|
|
||||||
#
|
|
||||||
# @staticmethod
|
|
||||||
# def get_default(dbms_id, hw_id):
|
|
||||||
# return Workload.__DEFAULT_FMT(db=dbms_id,
|
|
||||||
# hw=hw_id)
|
|
||||||
|
|
||||||
|
|
||||||
class PipelineRunManager(models.Manager):
|
class PipelineRunManager(models.Manager):
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,20 @@
|
||||||
<caption><h4 style="text-align: center;">{{ labels.title }}</h4></caption>
|
<caption><h4 style="text-align: center;">{{ labels.title }}</h4></caption>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 50%"><div class="text-right">{{ labels.dbms }}</div></td>
|
<td style="width: 50%"><div class="text-right">{{ labels.name }}</div></td>
|
||||||
<td style="width: 50%">{{ workload.dbms }}</td>
|
<td style="width: 50%">{{ workload.name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="text-right">{{ labels.name }}</div></td>
|
<td><div class="text-right">{{ labels.dbms }}</div></td>
|
||||||
<td>{{ workload.name }}</td>
|
<td>{{ workload.dbms }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div class="text-right">{{ labels.project }}</div></td>
|
||||||
|
<td>{{ workload.project }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div class="text-right">{{ labels.status }}</div></td>
|
||||||
|
<td>{{ workload.get_status_display }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue