Commit eedfa2c3 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

events: add pipeline types

Add a pipeline_type field to the Pipeline model. This will facilitate
grouping of pipelines into different classes.
parent a3530fe3
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-10 19:34
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('events', '0037_delete_approval_model'),
]
operations = [
migrations.AddField(
model_name='pipeline',
name='pipeline_type',
field=models.CharField(choices=[(b'E', b'external'), (b'O', b'other'), (b'SO', b'non-production search'), (b'SP', b'production search')], default='O', max_length=2),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-07-10 19:34
from __future__ import unicode_literals
from django.db import migrations
from events.models import Pipeline as pipeline_model
PIPELINES = [
('CWB', pipeline_model.PIPELINE_TYPE_SEARCH_PRODUCTION),
('MBTAOnline', pipeline_model.PIPELINE_TYPE_SEARCH_PRODUCTION),
('gstlal', pipeline_model.PIPELINE_TYPE_SEARCH_PRODUCTION),
('oLIB', pipeline_model.PIPELINE_TYPE_SEARCH_PRODUCTION),
('pycbc', pipeline_model.PIPELINE_TYPE_SEARCH_PRODUCTION),
('spiir', pipeline_model.PIPELINE_TYPE_SEARCH_PRODUCTION),
('CWB2G', pipeline_model.PIPELINE_TYPE_SEARCH_OTHER),
('Ringdown', pipeline_model.PIPELINE_TYPE_SEARCH_OTHER),
('X', pipeline_model.PIPELINE_TYPE_SEARCH_OTHER),
('HardwareInjection', pipeline_model.PIPELINE_TYPE_OTHER),
('Omega', pipeline_model.PIPELINE_TYPE_OTHER),
('Q', pipeline_model.PIPELINE_TYPE_OTHER),
('Fermi', pipeline_model.PIPELINE_TYPE_EXTERNAL),
('SNEWS', pipeline_model.PIPELINE_TYPE_EXTERNAL),
('Swift', pipeline_model.PIPELINE_TYPE_EXTERNAL),
]
DEFAULT_PIPELINE_TYPE = pipeline_model.PIPELINE_TYPE_OTHER
def update_pipeline_types(apps, schema_editor):
Pipeline = apps.get_model('events', 'Pipeline')
for p_tuple in PIPELINES:
p = Pipeline.objects.get(name=p_tuple[0])
p.pipeline_type = p_tuple[1]
p.save(update_fields=['pipeline_type'])
def revert_pipeline_types(apps, schema_editor):
Pipeline = apps.get_model('events', 'Pipeline')
for p_tuple in PIPELINES:
p = Pipeline.objects.get(name=p_tuple[0])
p.pipeline_type = DEFAULT_PIPELINE_TYPE
p.save(update_fields=['pipeline_type'])
class Migration(migrations.Migration):
dependencies = [
('events', '0038_pipeline_pipeline_type'),
]
operations = [
migrations.RunPython(update_pipeline_types, revert_pipeline_types),
]
......@@ -65,14 +65,30 @@ class Group(models.Model):
def __unicode__(self):
return self.name
class Pipeline(models.Model):
PIPELINE_TYPE_EXTERNAL = 'E'
PIPELINE_TYPE_OTHER = 'O'
PIPELINE_TYPE_SEARCH_OTHER = 'SO'
PIPELINE_TYPE_SEARCH_PRODUCTION = 'SP'
PIPELINE_TYPE_CHOICES = (
(PIPELINE_TYPE_EXTERNAL, 'external'),
(PIPELINE_TYPE_OTHER, 'other'),
(PIPELINE_TYPE_SEARCH_OTHER, 'non-production search'),
(PIPELINE_TYPE_SEARCH_PRODUCTION, 'production search'),
)
name = models.CharField(max_length=100)
# Are submissions allowed for this pipeline?
enabled = models.BooleanField(default=True)
# XXX Need any additional fields? Like a librarian email? Or perhaps even fk?
# Pipeline type
pipeline_type = models.CharField(max_length=2,
choices=PIPELINE_TYPE_CHOICES)
class Meta:
permissions = (
('manage_pipeline', 'Can enable or disable pipeline'),
)
def __unicode__(self):
return self.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