diff --git a/config/settings/base.py b/config/settings/base.py index 920498badf9fa70888eb4bbc104c5bd053ea2641..035a071fea00e5767c04680dd9c3c1a1089e62b8 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -228,12 +228,14 @@ COINC_PIPELINES = [ 'MBTAOnline', 'pycbc', 'MBTA', + 'PyGRB', ] GRB_PIPELINES = [ 'Fermi', 'Swift', 'INTEGRAL', 'AGILE', + 'CHIME', ] # List of pipelines that have been depreciated: diff --git a/gracedb/events/migrations/0082_add_PyGRB_pipeline.py b/gracedb/events/migrations/0082_add_PyGRB_pipeline.py new file mode 100644 index 0000000000000000000000000000000000000000..14890c8a946cb70a0e8739a074879ecaa8829e4e --- /dev/null +++ b/gracedb/events/migrations/0082_add_PyGRB_pipeline.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations +from events.models import Pipeline, Search + +# Creates initial search pipeline instances + +# List of search pipeline names +NEW_PIPELINES = [ + ('PyGRB', Pipeline.PIPELINE_TYPE_OTHER), + ('CHIME', Pipeline.PIPELINE_TYPE_EXTERNAL), +] + +NEW_SEARCHES = [ + 'FRB', +] + +def add_pipelines(apps, schema_editor): + Pipeline = apps.get_model('events', 'Pipeline') + Search = apps.get_model('events', 'Search') + + # Create pipelines + for pipeline_name in NEW_PIPELINES: + pipeline, created = Pipeline.objects.get_or_create(name=pipeline_name[0]) + pipeline.pipeline_type = pipeline_name[1] + pipeline.save() + + # Create searches + for search_name in NEW_SEARCHES: + search, created = Search.objects.get_or_create(name=search_name) + search.save() + +def remove_pipelines(apps, schema_editor): + Pipeline = apps.get_model('events', 'Pipeline') + Search = apps.get_model('events', 'Search') + + # Delete pipelines + for pipe in NEW_PIPELINES: + Pipeline.objects.filter(name=pipe[0]).delete() + + # Delete searches + for search in NEW_SEARCHES: + Search.objects.get(name=search).delete() + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0081_cwb_label_desc'), + ] + + operations = [ + migrations.RunPython(add_pipelines, remove_pipelines), + ] diff --git a/gracedb/events/translator.py b/gracedb/events/translator.py index e156b9a5f62271d442a8ab83336344207706314e..a622bd1e4fbf36bd65b4b6682d29e916844d19d1 100644 --- a/gracedb/events/translator.py +++ b/gracedb/events/translator.py @@ -109,7 +109,7 @@ def handle_uploaded_data(event, datafilename, pipeline = event.pipeline.name - if pipeline in [ 'gstlal', 'spiir', 'pycbc', ] or (pipeline in ['MBTA', 'MBTAOnline'] and '.xml' in datafilename): + if pipeline in [ 'gstlal', 'spiir', 'pycbc', 'PyGRB'] or (pipeline in ['MBTA', 'MBTAOnline'] and '.xml' in datafilename): log_comment = "Log File Created" # Wildly speculative wrt HM @@ -346,7 +346,7 @@ def handle_uploaded_data(event, datafilename, comment=comment) log.save() - elif pipeline in ['Swift', 'Fermi', 'SNEWS', 'INTEGRAL','AGILE']: + elif pipeline in ['Swift', 'Fermi', 'SNEWS', 'INTEGRAL','AGILE', 'CHIME']: # Get the event time from the VOEvent file error = None populateGrbEventFromVOEventFile(datafilename, event) diff --git a/gracedb/events/view_logic.py b/gracedb/events/view_logic.py index ed5a66dd9e1e5903cf100bd5d0b89da5ff83fd9d..1ee5cf2760974b7109c233ede68f4c61978873b4 100644 --- a/gracedb/events/view_logic.py +++ b/gracedb/events/view_logic.py @@ -54,9 +54,9 @@ def _createEventFromForm(request, form): else: search = None # Create Event - if pipeline.name in ['gstlal', 'spiir', 'MBTAOnline', 'MBTA', 'pycbc',]: + if pipeline.name in ['gstlal', 'spiir', 'MBTAOnline', 'MBTA', 'pycbc', 'PyGRB']: event = CoincInspiralEvent() - elif pipeline.name in ['Fermi', 'Swift', 'SNEWS','INTEGRAL','AGILE']: + elif pipeline.name in ['Fermi', 'Swift', 'SNEWS','INTEGRAL','AGILE', 'CHIME']: event = GrbEvent() elif pipeline.name in ['CWB', 'CWB2G']: event = MultiBurstEvent() diff --git a/gracedb/migrations/guardian/0018_populate_pygrb_uploaders.py b/gracedb/migrations/guardian/0018_populate_pygrb_uploaders.py new file mode 100644 index 0000000000000000000000000000000000000000..d358ac77f71d37dfb053ffff521f8b53b452af4f --- /dev/null +++ b/gracedb/migrations/guardian/0018_populate_pygrb_uploaders.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-11-01 16:19 +from __future__ import unicode_literals + +from django.db import migrations + +# Creates UserObjectPermission objects which allow specific users +# to add events for pipelines. Based on current production database +# content (27 October 2017) + +# List of pipeline names and lists of usernames who should +# be allowed to add events for them +PP_LIST = [ + { + 'pipeline': 'PyGRB', + 'usernames': [ + 'ryan.fisher@ligo.org', + 'brandon.oneal@ligo.org', + ] + }, + { + 'pipeline': 'CHIME', + 'usernames': [ + 'ryan.fisher@ligo.org', + 'brandon.oneal@ligo.org', + ] + }, +] + +def add_permissions(apps, schema_editor): + User = apps.get_model('auth', 'User') + Permission = apps.get_model('auth', 'Permission') + UserObjectPermission = apps.get_model('guardian', 'UserObjectPermission') + Pipeline = apps.get_model('events', 'Pipeline') + ContentType = apps.get_model('contenttypes', 'ContentType') + + perm = Permission.objects.get(codename='populate_pipeline') + ctype = ContentType.objects.get_for_model(Pipeline) + for pp_dict in PP_LIST: + pipeline, created = Pipeline.objects.get_or_create(name=pp_dict['pipeline']) + + # Loop over users + for username in pp_dict['usernames']: + + # Robot users should have been already created by ligoauth 0003, + # but we have to create human user accounts here + user, _ = User.objects.get_or_create(username=username) + + # Create UserObjectPermission + uop, uop_created = UserObjectPermission.objects.get_or_create( + user=user, permission=perm, content_type=ctype, + object_pk=pipeline.id) + +def remove_permissions(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('guardian', '0017_update_pycbc_uploaders'), + ('events', '0082_add_PyGRB_pipeline'), + ] + + operations = [ + migrations.RunPython(add_permissions, remove_permissions), + ]