diff --git a/config/settings/base.py b/config/settings/base.py index 3dadabc865a34dc86dbf755135b4276cf6b203c6..c1aad642e95b1857830e7464400ab77e6b66beca 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -262,6 +262,7 @@ GRB_PIPELINES = [ 'INTEGRAL', 'AGILE', 'CHIME', + 'SVOM', ] # List of pipelines that have been depreciated: diff --git a/gracedb/events/migrations/0090_add_svom_pipeline.py b/gracedb/events/migrations/0090_add_svom_pipeline.py new file mode 100644 index 0000000000000000000000000000000000000000..2c45e79820be5c6f735fe1b0fae20bf0a59e85db --- /dev/null +++ b/gracedb/events/migrations/0090_add_svom_pipeline.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +from django.db import migrations +from events.models import Pipeline, Search + +# Creates initial search pipeline instances + +# List of search pipeline names +NEW_PIPELINES = [ + ('SVOM', Pipeline.PIPELINE_TYPE_EXTERNAL), +] + +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() + +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() + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0089_alter_emobservation_group_and_more'), + ] + + operations = [ + migrations.RunPython(add_pipelines, remove_pipelines), + ] diff --git a/gracedb/events/translator.py b/gracedb/events/translator.py index 54218628d747fb5050caa692a2ad8f28c4a24bc6..f4009c0c5c0605e4b62fa4a12602b571478b7b45 100644 --- a/gracedb/events/translator.py +++ b/gracedb/events/translator.py @@ -346,7 +346,8 @@ def handle_uploaded_data(event, datafilename, comment=comment) log.save() - elif pipeline in ['Swift', 'Fermi', 'SNEWS', 'INTEGRAL','AGILE', 'CHIME']: + elif pipeline in ['Swift', 'Fermi', 'SNEWS', 'INTEGRAL', + 'AGILE', 'CHIME', 'SVOM']: # Get the event time from the VOEvent file error = None populateGrbEventFromVOEventFile(datafilename, event) @@ -725,8 +726,16 @@ def populateGrbEventFromVOEventFile(filename, event): # Fermi uses Trig_Dur or Data_Integ, while Swift uses Integ_Time # One or the other may be present, but not both VOEvent_params = vp.convenience.get_toplevel_params(v) + # Also grab parameters from embedded group if there, needed for SVOM + Svom_ident = vp.convenience.get_grouped_params(v).get('Svom_Identifiers') + Svom_detect = vp.convenience.get_grouped_params(v).get('Detection_Info') + if Svom_ident is not None: + VOEvent_params.update(Svom_ident) + if Svom_detect is not None: + VOEvent_params.update(Svom_detect) + trig_dur_params = ["Trig_Dur", "Trans_Duration", "Data_Integ", - "Integ_Time", "Trig_Timescale"] + "Integ_Time", "Trig_Timescale", "Timescale"] trigger_duration = None for param in trig_dur_params: if (param in VOEvent_params): @@ -742,7 +751,8 @@ def populateGrbEventFromVOEventFile(filename, event): # try to find a trigger_id value trigger_id = None - trigger_id_params = ['TrigID', 'Trans_Num', 'EventID'] + trigger_id_params = ['TrigID', 'Trans_Num', 'EventID', + 'Burst_Id'] for param in trigger_id_params: if (param in VOEvent_params): trigger_id = VOEvent_params.get(param).get('value') diff --git a/gracedb/events/view_logic.py b/gracedb/events/view_logic.py index 3322e9251d9afed519eccf1e95ad00b8254726b2..f1199469af8a29ef7e9f58cb56a408ea56bfb61a 100644 --- a/gracedb/events/view_logic.py +++ b/gracedb/events/view_logic.py @@ -56,7 +56,8 @@ def _createEventFromForm(request, form): # Create Event if pipeline.name in ['gstlal', 'spiir', 'MBTAOnline', 'MBTA', 'pycbc', 'PyGRB']: event = CoincInspiralEvent() - elif pipeline.name in ['Fermi', 'Swift', 'SNEWS','INTEGRAL','AGILE', 'CHIME']: + elif pipeline.name in ['Fermi', 'Swift', 'SNEWS','INTEGRAL','AGILE', 'CHIME', + 'SVOM']: event = GrbEvent() elif pipeline.name in ['CWB', 'CWB2G']: event = MultiBurstEvent() diff --git a/gracedb/migrations/guardian/0021_populate_svom_uploaders.py b/gracedb/migrations/guardian/0021_populate_svom_uploaders.py new file mode 100644 index 0000000000000000000000000000000000000000..4fdde1e478cc56648ee8acceca36e58b82216f55 --- /dev/null +++ b/gracedb/migrations/guardian/0021_populate_svom_uploaders.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# supports: https://git.ligo.org/computing/gracedb/server/-/issues/338 + +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': 'SVOM', + 'usernames': [ + 'brandon.piotrzkowski@ligo.org', + 'naresh.adhikari@ligo.org', + 'rachel.hamburg@ligo.org', + 'emfollow', + ] + }, +] + +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', '0020_populate_aframe_uploaders'), + ('events', '0090_add_svom_pipeline'), + ] + + operations = [ + migrations.RunPython(add_permissions, remove_permissions), + ]