From 182f4ed42c947b72e1b4c167157d63ab56338c1c Mon Sep 17 00:00:00 2001 From: Alexander Pace <alexander.pace@ligo.org> Date: Fri, 28 Jul 2023 14:25:56 +0000 Subject: [PATCH] Add PyGRB and CHIME pipelines - New pipelines - New FRD search - Add upload permissions for brandon.oneal and ryan.fisher --- config/settings/base.py | 2 + .../migrations/0082_add_PyGRB_pipeline.py | 54 +++++++++++++++ gracedb/events/translator.py | 4 +- gracedb/events/view_logic.py | 4 +- .../guardian/0018_populate_pygrb_uploaders.py | 66 +++++++++++++++++++ 5 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 gracedb/events/migrations/0082_add_PyGRB_pipeline.py create mode 100644 gracedb/migrations/guardian/0018_populate_pygrb_uploaders.py diff --git a/config/settings/base.py b/config/settings/base.py index 920498bad..035a071fe 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 000000000..14890c8a9 --- /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 e156b9a5f..a622bd1e4 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 ed5a66dd9..1ee5cf276 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 000000000..d358ac77f --- /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), + ] -- GitLab